1- create a xml file and save in your debug folder or where your application start
<xml>
<foo>
<baz id="1">10</baz>
<bar id="2" special="1">baa baa</bar>
<baz id="3">20</baz>
<bar id="4" />
<bar id="5" />
</foo>
<foo id="123">Text 1<moo />Text 2
</foo>
</xml>
Bellow is the code for retrive the data
string fpath = Application.StartupPath + "\\" + "test.xml";
XDocument xele = XDocument.Load(fpath);
var node = xele.XPathSelectElement("/xml/foo[@id='123']");
var nodes = xele.XPathSelectElements(
"//moo/ancestor::xml/descendant::baz[@id='1']/following-sibling::bar[not(@special='1')]");
var sum = xele.XPathEvaluate("sum(//foo[not(moo)]/baz)");
Add the bellow name spaces in your page
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;