Finding attribute value of some unspecified ancestor using Xpath -


i find xpath expression select nodes, attribute 'a' value exists , concatenation of attribute 'b' , value of 'a' of first ancestor, attribute 'a' exists, or such nodes, first in hierarchy, have attribute 'a'.

<a a='town/'>  <b>   <c a='town/street' b='street'>     <d a='town/street' b='street'>     <e a='town/street/house' b='street'></e>     <f a='town/street/house' b='house'>      <g a='town/street/house' b='house' ></g>     </f>    </d>   </c>  </b> </a> 

the xpath should pick elements a, c , f tried \\*[(@a = concat(ancestor::*[@a][1]/@a,'/',@b)) or (not(ancestor::*[@a])], not work intended.

can please help? thank you.

first, you're using backslashes instead of slashes in beginning of query. then, input inconsistent (or copy&paste error?), there slash in end in //a/@a, not in other @a attributes. when removing (so <a a='town'>...</a>, xpath query want:

//*[@a = concat(ancestor::*[@a][1]/@a, '/', @b) or not(ancestor::*[@a])] 

if cannot change input, check versions both adding slash , not adding it:

//*[@a = concat(ancestor::*[@a][1]/@a, '/', @b) or @a = concat(ancestor::*[@a][1]/@a, @b) or not(ancestor::*[@a])] 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -