ruby - Finding last line within node with XPath -


i wondering if there way select content of node above element?

i have following code want extract from:

<div id="somediv">    <h3>name</h3>    content1    <br/>    <br/>    address 12345    <br/>    09876 city, country    <br/>    <span id="tel_number">12345</span> </div> 

here xpath finds content of above span:

//div[@id="somediv"]/span[@id="tel_number"]/preceding-sibling::node() 

now, need xpath selects content right above span , nothing else(a single line). should work if (for reason) <br/> above span missing.

hope can that!

try:

(//div[@id="somediv"]/span[@id="tel_number"]/preceding-sibling::text())[last()] 

or if want remove whitespace

normalize-space((//div[@id="somediv"]/span[@id="tel_number"]/preceding-sibling::text())[last()]) 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -