html - Xpath: extract value from element using text outside of element -


i want extract @name values input elements below.

<div style="style info"> <input type="checkbox" name="name1" onchange="dosomething;"/> mobile <br/> <input type="checkbox" name="name2" onchange="dosomething;"/> event <br/> </div> 

in above example, want extract name ("name1") relates "mobile".

i need one-line xpath can retrieve information me. have tried

//div[normalize-space(text())='mobile']/preceding-sibling::input/@name  //div[normalize-space(text())='mobile']/input/@name  //div[normalize-space(.)='mobile']/preceding-sibling::input/name 

and several other guesses after combing archives here, have not found works (i new xml, can no doubt tell; sorry if guesses seem haphazard).

thanks in advance answers, , please let me know if there clarifications or corrections can make assist in solving this. extremely appreciated!

note: xslt not option me

you want locate text node of interest first, rather div. there, can go preceding-sibling have tried.

try:

//text()[normalize-space() = "mobile"]/preceding-sibling::input/@name 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -