Access the sibling nodes from current node in XPath -


<div class="form-group value">     <label>text         <a href="#" class="">             <span class="glyphicon glyphicon-pencil"></span>         </a>     </label>     <div>         <input/>     </div> </div> 

can access span element class glyphicon glyphicon-pencil input element.

one of simplest way maybe using preceding axis find previous elements relative current context element regardless of parent/level (i assume current context element here <input/> element) :

preceding::span[@class='glyphicon glyphicon-pencil'] 

contrasts preceding-sibling axis match previous element within same parent (in other words, previous element @ same level).


Comments