I have a following xml file
<root>
<element1>
<header>header1</header>
<tag1>tag1</tag1>
<response>
<status>success</status>
<Data>
<id>d1</id>
<test>2</test>
</Data>
<Beta>
<betaid>sdsd</betaid>
<code>123</code>
<code>ddd</code>
</Beta>
</response>
</element1>
</root>
My Question: How to get the first child elements under "Response" tag? i.e staus, data and beta. Using XPath in C#. Thank you
The .net code i have is here but it does not work.
XPathDocument doc= new XPathDocument(XmlReaderdata);
XPathNavigator mes, Nav = doc.CreateNavigator();
foreach(XPathNavigator node in (XPathNodeIterator)Nav.Evaluate("//response/*)
{
node.Name;
}
An XPath query like this should work:
For example:
Produces the output: