Finding last line within node with XPath
I was wondering if there was a way to always select the content of a node
above a certain element?
I have the following code that I want to extract from:
<div id="someDiv">
<h3>Name</h3>
Some content1
<br/>
<br/>
Address 12345
<br/>
09876 City, Country
<br/>
<span id="tel_number">12345</span>
</div>
Here is the XPath that finds the content of everything above the span:
//div[@id="someDiv"]/span[@id="tel_number"]/preceding-sibling::node()
Now, what I need is an XPath that always selects the content right above
the span and nothing else(a single line). It should also work if (for some
reason) the <br/> above the span was missing.
Hope that somebody can help with that!
No comments:
Post a Comment