Reputation: 61
Hi i have been trying to get all the text part within the div - p tags up to the hr tag so somebody gave this xpath
//div[@class="entry"]/*[not(preceding-sibling::hr | self::hr)]/text()
which works fine but this ignores the text part within the <.a> tag in the p tag any ideas to grab that text as well?
<div class="entry">
<p> some text</p>
<p> some text2</p>
<p> some text3</p>
<p> some text4
<a href='somelink'> this text here i want to get through xpath</a>
some text5
</p>
<hr>(up to this hr tag)
<p> some text5</p>
<hr>
<p> some text6</p>
</div>
Upvotes: 0
Views: 75
Reputation: 9
You can simply pull data based on xpath.
//div[@class="entry"]/p[0]
//div[@class="entry"]/p[1]
//div[@class="entry"]/p[2]
//div[@class="entry"]/p[3]
//div[@class="entry"]/p[4]
//div[@class="entry"]/p[5]
Upvotes: 0
Reputation: 167726
One way might be //div[@class="entry"]/*[not(preceding-sibling::hr | self::hr)]//text()
though I might prefer to simply select the elements //div[@class="entry"]/*[not(preceding-sibling::hr | self::hr)]
and use the string value.
Upvotes: 1