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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -