BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
System.XML
System.Xml.XmlDeclaration Class
System.Xml.XmlDataDocument Class
System.Xml.XmlConvert Class
System.Xml.XmlComment Class
System.Xml.XmlCharacterData Class
System.Xml.XmlCDataSection Class
System.Xml.XmlAttributeCollection Class
System.Xml.XmlAttribute Class
<< SQL XML
Uncategorized >>

By :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

        Dim objDoc As New System.Xml.XmlDocument

        Dim strProperties As String

        objDoc.Load("c:\sample.xml")

        strProperties = "XmlDocument.BaseURI: " & objDoc.BaseURI & CrLf

        strProperties &= "XmlDocument.DocumentElement.Name: " & objDoc.DocumentElement.Name & CrLf

        strProperties &= "XmlDocument.HasChildNodes: " & objDoc.HasChildNodes & CrLf

        strProperties &= "XmlDocument.IsReadOnly: " & objDoc.IsReadOnly & CrLf

        strProperties &= "XmlDocument.Name: " & objDoc.Name & CrLf

        strProperties &= "XmlDocument.NodeType: " & objDoc.NodeType & CrLf

        TextBox1.Text = strProperties

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.

        Dim objDoc As New System.Xml.XmlDocument

        Dim objNode As System.Xml.XmlNode

        objDoc.Load("c:\sample.xml")

        objNode = objDoc.CreateNode(XmlNodeType.Element, "SampleNode", "")

        objNode.InnerText = "Sample Data"

        objDoc.LastChild.AppendChild(objNode)

        TextBox1.Text = objDoc.OuterXml


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

Software Developers Needed in Charl
Sr. Software Engineer - Analytics
Immediate Mainframe openings for Ch
Immediate TANDEM-TAL openings for C
Immediate ASP.NET/C# Openings for C

View all Jobs (Add yours)
View all CV (Add yours)



online fax service
swimming pool contractor
conference calling
water softener
Teleconference
Host Department NOLIMIT Web Hosting
MSN
sunglasses


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP