Read XML Using XPathNavigator
Small schematic snippet that demonstrates best practices reading XML in C#. The code uses XPathNavigator to navigate through XML document. The use of XPathNavigator produces fast and readable implementation.
using System; using System.Xml; using System.Xml.XPath; namespace Messaging { public class MyCode { public MyCode() {} public void ImCallingYou() { XmlReader reader = new XmlTextReader("input.xml"); XPathDocument doc = new XPathDocument(reader); XPathNavigator nav = doc.CreateNavigator(); this.CallMe(nav); } public void CallMe(XPathNavigator yourstuff) { } } }
Saturday, January 10, 2004 6:31 AM