Navigating the XML DOM

Now that the XmlDocument is loaded, you can navigate its tree structure. Usually, you'll want to skip the XML declaration and other elements in the prolog and start directly at the root node. This can be done by using the DocumentElement property. This property returns the root element of the node tree.

The XmlDocument can be thought of as a node tree with links both down and up the tree. This allows for navigation in all directions: parent to child, child to parent, and sibling to sibling. The XmlNode abstract base class provides several methods for navigating the tree structure.

Navigating Using HasChildNodes and ChildNodes

The XmlNode provides the HasChildNodes property as an easy way to check whether the node is linked ...

Get Microsoft® .NET Compact Framework Kick Start now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.