SAAN
SAAN

Reputation: 3

I want the xpath to get the all the text in <strong> tag, the problem is that there is a strong within strong tag and the i want is from both strong

The HTML code is given below, i want all the text in <p> tag including text in both <strong> tags.

<p>
      <strong>
              <strong class="location">لاہور:&nbsp;</strong>
              پاکستانی اداکار فواد خان کا کہنا ہے کہ پاکستان اور انڈیا کے درمیان سیاسی تناؤ کا اثر ان کے بالی وڈ میں موجود افراد سے تعلقات پر بالکل نہیں پڑا لیکن موجودہ صورتحال میں ساتھ کام کرنا آسان نہیں ہے۔
      </strong>
    </p>

Upvotes: 0

Views: 33

Answers (2)

markfila
markfila

Reputation: 460

if I reading your question correctly you just want the text in the strong elements and not all the html

this should get the text in the first strong element

$x("//p/strong/text()[last()]")

and this should get the text in the nested strong element

$x("//p/strong/strong/text()")

Upvotes: 0

SuperUser
SuperUser

Reputation: 4822

Use double backslash

//p//strong/text()

Upvotes: 1

Related Questions