c# - Select child of current node based on attribute value in XPath? -
i have xml
... <s head="x"> <a head="x"> <a1 head="z"> <a2 head="x"> <b head="y"> </s> ...
i select child of s
has attribute value "x". (note know nothing names of elements s
, a
, b
...)
i tried
string headtag = node.selectsinglenode("//*[@head='x']").name;
it returns "s", while expect "a" if node
points s
, "a2" if node
points a
.
this xpath select of child elements, regardless of name, @head
attribute value equal x
:
./*[@head='x']
starting current node.
when current node s
, it'll select a
; when current node a
, it'll select a2
, requested.
Comments
Post a Comment