aBlaze
aBlaze

Reputation: 2726

Xpath: How to get text located outside of any html tag

I have the following HTML:

<div class="container">
   <div class="inner_container">
       This is <strong>text</strong> I don't want to extract.
   </div>
</div>
<br/>This is the text I'd like Xpath to extract

Using xpath, how can I extract "This is the text I'd like Xpath to extract"

Upvotes: 0

Views: 166

Answers (1)

Bouke
Bouke

Reputation: 1614

In case the provided HTML is just a fragment and there is a single root element, the text can be selected by the following XPath expression:

//br/following-sibling::text()[1]

Upvotes: 1

Related Questions