So I need to parse some XML for my SDP project (C# windows application). I know you can parse XML with the regular .NET Xml class, but I saw XPath. It’s bad ass. It navigates through your XML file with ease. Check out the sample:
//Load the XML document
XmlTextReader(“trafficInfo.xml”);
XmlDocument doc = new XmlDocument();
doc.Load(new XmlTextReader(“trafficInfo.xml”));
//Create XPathNavigator
XPathNavigator xpathNav = doc.CreateNavigator();
//Create XPathIterator
string xpathStr = “/items/current/city”;
XPathNodeIterator xIterator = xpathNav.Select(xpathStr);
MessageBox.Show(xIterator.Current.Value.ToString());
//XML file
<?xml version=”1.0″ encoding=”UTF-8″ ?>
<items>
<current>
<city>Detroit</city>
</current>
</items>
More Articles on XPath:
http://perfectxml.com Article
MSDN Library Article
P.S. I wish Blogger had tags. It’d make things so much more organized.