XmlNode.InnerXml Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the markup representing only the child nodes of this node.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

abstract InnerXml : string with get, set
override InnerXml : string with get, set

Property Value

Type: System.String

The markup of the child nodes of this node.

System_CAPS_noteNote

InnerXml does not return default attributes.

Exception Condition
InvalidOperationException

Setting this property on a node that cannot have child nodes.

XmlException

The XML specified when setting this property is not well-formed.

Attempting to set this property from a node that cannot have child nodes, for example a Text node, throws an exception. Otherwise, setting InnerXml replaces the child nodes, of the node, with the parsed contents of the given string. The parsing is done in the current namespace context.

This property is a Microsoft extension to the Document Object Model (DOM).

System_CAPS_noteNote

InnerXml is not an efficient way to modify the DOM. There may be performance issues when replacing complex nodes. It is more efficient to construct nodes and use methods such as InsertBefore, InsertAfter, AppendChild, and RemoveChild to modify the Xml document.

The following example compares the InnerText and InnerXml properties.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top
Show: