ruby on rails - Select following-sibling if element unknown -


i want select first sibling of tag html element. lets want <a> follows <span>:

<span id="unique"></span> <a href="#"> 

this can done following xpath:

//div[@id="unique"]/following-sibling::a 

this, however, specific in way looks <a> tag. how can make more generic find tag long first sibling element selected?

write below

//span[@id="unique"]/following-sibling::*[1] 

here sample html :

<div>     <span id="unique"></span>     <p>foo</p>     <p>bar</p> </div> 

xpath expression:

//span[@id="unique"]/following-sibling::*[1] 

output

<p>foo</p> 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -