BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
System.XML
System.Xml.XmlDocumentType Class
System.Xml.XmlDocumentFragment Class
System.Xml.XmlDocument Class
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 :392

 

The System.Xml.XmlElement 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

FirstChild 

CreateNavigator 

HasAttributes

Equals

HasChildNodes 

GetAttribute

InnerText

GetAttributeNode

InnerXml

GetElementsByTagName

IsEmpty

GetEnumerator 

IsReadOnly 

GetHashCode

LastChild 

GetNamespaceOfPrefix 

LocalName

GetPrefixOfNamespace 

Name

GetType

NamespaceURI

HasAttribute

NextSibling

InsertAfter 

NodeType

InsertBefore 

OuterXml 

Normalize 

OwnerDocument

PrependChild 

ParentNode 

RemoveAll

Prefix

RemoveAllAttributes

PreviousSibling 

RemoveAttribute

Value

RemoveAttributeAt

RemoveAttributeNode

RemoveChild 

ReplaceChild 

SelectNodes 

SelectSingleNode 

SetAttribute

SetAttributeNode

Supports 

ToString

WriteContentTo

WriteTo 

Overview

Another core part of the System.Xml class library, the XmlElement class represents element nodes within XML documents. It contains many important methods, including a variety of Get, Insert, and Remove methods used to manipulate the structure and content of XmlDocument objects.

Example (VB.NET): Two ways to loop through an XML document's XmlElement nodes.

In the example below we demonstrate how to step through the contents of an XML document in order to extract XmlElement node information. The first For Each construct loops through the XmlDocument.DocumentElement.ChildNodes collection and looks for any nodes that are XmlElements. It then displays properties of each element. The second For Each construct does the same, except that this time we look for all nodes within the ChildNodes collection, and then test each node to determine whether it is of type “Element”, prior to displaying its properties.

        Dim objDocument As New System.Xml.XmlDocument

        Dim objElement As System.Xml.XmlElement

        Dim objXmlNodeList As System.Xml.XmlNodeList

        Dim objXmlNode As System.Xml.XmlNode

        Dim strValues As String

        objDocument.LoadXml("<sampleElement1><sampleElement2>We are demonstrating XML.</sampleElement2></sampleElement1>")

        objElement = objDocument.DocumentElement

        objXmlNodeList = objDocument.DocumentElement.ChildNodes

        strValues = "XmlElement: " & CrLf

        For Each objElement In objXmlNodeList

            strValues &= "objElement.Name = " & objElement.Name & CrLf

            strValues &= "objElement.InnerText = " & objElement.InnerText & CrLf

            strValues &= "objElement.OuterXml = " & objElement.OuterXml & CrLf

            strValues &= "objElement.ParentNode.Name = " & objElement.ParentNode.Name & CrLf

        Next

        objXmlNode = objDocument.DocumentElement

        objXmlNodeList = objXmlNode.ChildNodes

        strValues &= CrLf & "XmlNodes of type XmlElement: " & CrLf

        For Each objXmlNode In objXmlNodeList

            If objXmlNode.NodeType = XmlNodeType.Element Then

                strValues &= "objXmlNode.Name = " & objXmlNode.Name & CrLf

                strValues &= "objXmlNode.InnerText = " & objXmlNode.InnerText & CrLf

                strValues &= "objXmlNode.OuterXml = " & objXmlNode.OuterXml & CrLf

                strValues &= "objXmlNode.ParentNode.Name = " & objXmlNode.ParentNode.Name & CrLf

            End If

        Next

        strValues &= CrLf & "These two lists should be the same."

        TextBox1.Text = strValues


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)



it outsourcing
swimming pool builder
conference call for CA
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