System.Xml.XmlNode.InnerXml Property

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

Syntax

public virtual string InnerXml { get; set; }

Value

The contents of the node as an Xml string. When getting the value of this property, InnerXml returns the same string that XmlNode.WriteContentTo would write to an System.Xml.XmlTextWriter.

When setting the value of this property, the value is parsed as Xml, and the current children of the node are replaced by the nodes parsed from the string.

Remarks

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).

Note:

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.

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0