.NET Beta 2 and Navigation in XML Documents

.NET Beta 2 was released yesterday at tech-ed, 2001, Atlanta. Many things have been changed in Beta 2 since Beta 1. In this article, I'll cover changes in XmlNavigator class replaced with XPathNavigator.

XmlNavigator Class

XmlNavigator class is used to navigate an XML document in Beta 1. I was revising XML.NET chapter of my Beta 1 based code and found XmlNavigator class unavailable. The new class appreared in Beta 2 is XPathNavigator. You use two classes to navigate through XML documents - these classes XPathDocument and XPathNavigator

The XPathDocument class provides a fast cache for XML document processing using XSLT and XPath.You use XPathDocument constructor to create an instance of XmlPathDocument. Constructor has various overridables. You can pass an XmlReader, TextReader, or even direct XML file names. For example:

XmlPathDocument xmlDoc = new XmlPathDocument("C:\\XmlDataDoc.xml");

XPathNavigator Class

The XPathNavigator class implements the functionality to navigate through a document. It has easy to use and self-explanatory methods. You create XPathNavigator instance by calling XPathDocument's CreateNavigator method.

XPathNavigator navigator = xmlDoc.CreateNavigator();

XPathNavigator Move Methods

XPathNavigator provides enough methods to traverse through a document as a tree. Some of these methods are MoveToFirst, MoveToLast, MoveToId, MoveToRoot, MoveToNext, MoveToPrevious, MoveToParent .....

I think you should check out by yourself now ;). I had a long day today. Sprint PCS service scuks and they took my hour and half to replace my buggy cell with new refurbished cell. Hopefully I'll get it in a week or so. Oh shoot.. I've to watch two movies too .. Tomb Raider and SwordFish. Man .. I can't wait to see these movies. Hopefully, I'll hit theater this week end. What u think? Not a bad idea.

I hope you find something new in Beta 2 and share with us. You can send me your innovation at [email protected]. Thanks.


Similar Articles
Mindcracker
Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.