i'm using xml file this;
<m> <n> <name id="1">test</name> <id>10</id> </n> <n> ...... </n> </m>
want search 10 sibling tag "name"'s id value.
i'm finding 10 below , ,dont know how sibling tag "name"'s id attribute value, there method accessing sibling's attribute?
$test=$xml->xpath("//n['10']/::*");
how can access id ("<name id="1">test</name>
") value?
thanks
you can find preceding sibling name
element id
element follow :
//id[.='10']/preceding-sibling::name
alternatively, can find n
element child id
matches criteria, , return name
element such n
:
//n[id='10']/name
*) add /@id
@ end of either xpath above if meant return id
attribute instead of entire name
element.
Comments
Post a Comment