System.XML
XMLElement
System.XML.XMLElement
Represents an attribute
Valid and default values for the attribute are defined in the document type definition
By default an XML element name is determined by the class or member name
For example a class called MyClass with a field named MyFlag produces an XML element tag <MyFlag>
This default behaviur can be changed if you want to give you element a different name.
Dim objXMLElement As System.XML.XMLElement
With objXMLElement
.AppendChild
.InnerText
.SetAttribute
End With
An element can have one or more attributes
XMLNode
System.XML.XMLNode
Represents a single node in the XML document.
objXMLDocument.ChildNodes.Item(2).InnerXML
.SelectNodes("---") ??
XMLNodeList
System.XML.XMLNodeList
XMLDocument
System.XML.XMLDocument
Introduced in .NET 1.1
This allows you to browse the nodes in any direction, insert and remove nodes and change the structure on the fly.
Loads the entire XMLDocument into memory.
You can have problems when using this method because the data model is different to XSLT and Xpath
This is based on the Document Object Model (www.w3c.org/DOM)
Access to data in a non-sequential way
Load - loads from a string, stream, text reader, xml reader
LoadXML - loads from a string
If you want a more memory-efficient alternative and you can process the XML bit by bit, consider using the XMLReader and XMLWriter classes.
The XMLDocument class is an XML parser which stores the contents in memory
An XPathNavigator can be created over the content to provide easy access to nodes and values
This class implements W3C level 2 XML DOM core functionality.
Dim objXMLDocument As System.XML.XMLDocument
WIth objXMLDocument
.CreateXMLDeclaration
.InsertBefore
.InsertAfter
.CreateElement
End With
XMLAttribute
System.XML.XMLAttribute
An element can have one or more attributes
Attributes can be used to control the XML serialization on an object.
<System.Xml.XmlAttribute("name")>
XMLDataDocument
System.XML.XMLDataDocument
This is now obselete
This class is inherited from XMLDocument and exposes the XML content as an ADO.NET DataSet instance.
This should only be used when you need to access your data as a DataSet.
It was used to allow structured data to be stored, retrieved and manipulated strough a relational DataSet.
XMLReader
System.XML.XMLReader
This is an abstract class with the following derived classes
XMLTextReader
XMLNodeReader
XMLValidatingReader
XMLDictionaryReader
Creating a XMLReader instance
Starting from .NET 2.0 it is recommended not to create an instance of one of these derived classes directly but to create an XMLReader instance by using the Create method.
The XMLReaderSettings class is used to specify the set of features you want to enable on the XMLReader object.
The advantage of using the XMLReaderSettings is that it can be reused when creating other XMLReaders.
XMLReaderSettings
System.XML.XMLReaderSettings
List of Properties
CheckCharacters
ConformanceLevel
IgnoreComments
IgnoreProcessingInstructions
IgnoreWhitespace
LineNumberOffset
LinePositionOffset
NameTable
DtdProcessing
ProhibitDtd
Schemas
ValidationFlags
ValidationType
XMLResolver
XMLTextReader
System.XML.XMLTextReader
XMLWriter
System.XML.XMLWriter
This works exactly the same as the Xml.XMLReader class but in reverse
Similar to the XMLReader class there is an XMLWriterSettings object.
XMLTextWriter
System.XML.XMLTextWriter
XMLWriterSettings
System.XML.XMLWriterSettings
XPathDocument
System.XML.XPath.XPathDocument
Introduced in .NET 2.0
Read-only
optimised for Xpath queries
This is the preferred method when using XSLT transformations
XPathNavigator
System.XML.XPath.XPathNavigator
To access any data in an XPathDocument you must create an XPathNavigator.
The XPathDocument is similar to the XMLDocument class however it doesn't build a tree of XML nodes in memory but processes them one node at a time.
The main purpose of the XPathDocument class is to perform Xpath queries and XSL transformations
This is read-only and does not support the W3C XML DOM functionality making it leaner and much faster.
An XPathNavigator must be created over the top in order to access the content and this class provides no read support directly.
There is no Load method because you create your XPathDocument by specifying the source in the constructor.
Dim objXPathNavigator As System.XML.Xpath.XPathNavigator
objXPathNavigator = objXPathDocument.CreateNavigator
MoveTo -
MoveToFirstChild - moves to the first child node of the current node.
MoveToFirstAttribute - moves to the first attribute of the current node.
MoveToAttribute - moves to the attribute with the matching local name
MoveToNext - moves to the next child node of the current node.
SelectSingleNode - selects a single node using a given Xpath.
There is a lof of confusion over when to use an element and when to use an attribute in XML so you will probably come across all kinds of data representation.
This makes is particularly useful to know exactly how to select the data you want.
| ./element_name | all "element_name" elements within the current context |
| element_name | same as above |
| one.two | all "one.two" elements within the current context |
| /document_element | the document element "document_element" of this document |
| //element_name | all "element_name" elements in this document |
| element_name[document_element/ @attribute1=@attribute2] | all "element_name" elements whose "attribute2" attribute is equal to the "attribute1" attribute of the "document_element" at the root of the document |
| element_name1/element_name2 | all "element_name2" elements that are children of an "element_name1" element |
| .//element_name | all "element_name" elements one or more levels deep in the current context |
| ./element_name all "element_name" elements within the current context |
| element_name same as above |
| one.two all "one.two" elements within the current context |
| /document_element the document element "document_element" of this document |
| //element_name all "element_name" elements in this document |
| element_name[document_element/ @attribute1=@attribute2] all "element_name" elements whose "attribute2" attribute is equal to the "attribute1" attribute of the "document_element" at the root of the document |
| element_name1/element_name2 all "element_name2" elements that are children of an "element_name1" element |
| .//element_name all "element_name" elements one or more levels deep in the current context |
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrev