Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :
03/24/2008
Times viewed :
1187
The System.Xml.XmlDocument Class
Supported Versions
.NET Framework 1.0, 1.1, 1.2
Public Members
Bold members are covered in the sample code.
Public Properties
Public Methods
Attributes
AppendChild
BaseURI
Clone
ChildNodes
CloneNode
DocumentElement
CreateAttribute
DocumentType
CreateCDataSection
HasChildNodes
CreateComment
Implementation
CreateDocumentFragment
InnerText
CreateDocumentType
InnerXml
CreateElement
IsReadOnly
CreateEntityReference
Item
CreateNavigator
LastChild
CreateNode
LocalName
CreateProcessingInstruction
Name
CreateSignificantWhitespace
NamespaceURI
CreateTextNode
NameTable
CreateWhitespace
NextSibling
CreateXmlDeclaration
NodeType
Equals
OuterXml
GetElementById
OwnerDocument
GetElementsByTagName
ParentNode
GetEnumerator
Prefix
GetHashCode
PreserveWhitespace
GetNamespaceOfPrefix
PreviousSibling
GetPrefixOfNamespace
Value
GetType
XmlResolver
ImportNode
InsertAfter
InsertBefore
Load
LoadXml
Normalize
PrependChild
ReadNode
RemoveAll
RemoveChild
ReplaceChild
Save
SelectNodes
SelectSingleNode
Supports
ToString
WriteContentTo
WriteTo
Overview
XMLDocument is a fundamental building block of the
System.Xml class hierarchy. It essentially inherits and extends the XMLNode
class, and represents a W3C DOM-compliant XML document in its entirety. Once
created or loaded into memory, its contents can be accessed, edited, and
manipulated.
Key methods of this class include Load and LoadXml. The
former is primarily used to retrieve XML using a resource path, whereas the
latter accepts a string value consisting of an XML document or fragment. The
InnerText, InnerXml, and OuterXml properties conveniently allow you to retrieve
values and XML markup from a document. Below are three examples demonstrating
the use of the XMLDocument class.
Example (VB.NET):
How to load an XML document into memory using the XMLDocument.Load method.
This first example simply uses the Load method and
InnerText property of the XMLDocument class to load an existing document into
memory and display its contents.
Dim objDoc As New System.Xml.XmlDocument
objDoc.Load("c:\sample.xml")
TextBox1.Text = objDoc.InnerText
Example (VB.NET):
How to display XMLDocument properties.
This example uses the XMLDocument class to load an XML
document and displays a series of properties
Example (VB.NET):
How to use the XMLDocument.LastChild.AppendChild method to append a new node to
an XML document.
This third example actually changes the structure of the
loaded document by first creating an XMLNode object using the
XMLDocument.CreateNode method, and then assigning this node a value via its
InnerText property. The node is finally appended and its value displayed, using
the XMLDocument.LastChild.AppendChild method and the XMLDocument.OuterXml
property.