Home > Articles > Web Services > XML

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

Key Extended Nodes

Several key extended nodes build on the foundation of XmlNode and provide the key structures in the architecture of an XmlDocument: XmlElement, XmlAttribute, XmlTextNode, and XmlDocument. XmlElement contains additional methods for accessing the collection of child attribute nodes that it contains in an efficient manner. It also contains the DOM-compliant element node search functionality in the GetElementsByTagName method. The XmlAttribute node provides a simple extension to retrieve the parent element through an OwnerElement property. XmlTextNode doesn't provide extended properties, but it is important because it is the workhorse node that composes character data for simple element content in the document.

These are the XmlElement extended methods:

  • GetAttribute

  • GetAttributeNode

  • RemoveAttribute

  • RemoveAttributeNode

  • SetAttribute

  • SetAttributeNode

  • HasAttribute

  • GetElementsByTagName

XmlAttribute has one method for extended navigation: OwnerElement.

The most important extended node is the XmlDocument class. In the code examples shown previously, the XmlDocument takes on the responsibility of parsing and loading the source XML file. The following list shows the basic I/O methods. Load and Save work with a variety of I/O objects—Stream, XmlReader/XmlWriter, TextReader/TextWriter—and from the filesystem. LoadXml has the unique in that it provides the capability to read from a string. You also can use the OuterXml property on the XmlDocument that other XmlNode elements share to grab or set the string representation of the document content.

  • Load

  • LoadXml

  • Save

XmlDocument provides extended navigation functionality similar to that of XmlElement, as shown in the next list. It supports GetElementsByTagName and adds a GetElementsByID for documents that utilize ID/IDREF style attributes on elements. It also provides easy access to the topmost document element of the document through the DocumentElement property. The DocumentType property provides access to an XmlDocumentType node that holds Entity and Notation collections.

  • DocumentElement

  • DocumentType

  • GetElementsByTagName

  • GetElementsByID

  • + Share This
  • 🔖 Save To Your Account