xml - Get root attribute value based on current node value -
i'm trying grab value of attribute @ root node based on value of current node.
example:
<root src="bob" att="mark"> <div> <p>my name <ref bar="src"/>.</p> <p>my name <ref bar="att"/>.</p> </div> </root> my name bob.
my name mark.
i have xpath far. works until i'm trying test name based on local attribute value provided in @bar. @bar has name of attribute in root need pull value.
this works...
/*/@*[name()='src'] this doesn't.
/*/@*[name()=@bar] the value i'm hoping value of @src, "foo" within p tag.
i have use xpath 1.0.
edited: i'm trying path of ref tag wich should current node.
/*/@*[name()=//ref[count(preceding::ref)]/@bar] any appreciated!
you need have path bar attribute in predicate.
/*/@*[name()=../div/p/ref/@bar]
Comments
Post a Comment