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
Post a Comment