XmlElement::InnerXml Property
.NET Framework (current version)
Gets or sets the markup representing just the children of this node.
Assembly: System.Xml (in System.Xml.dll)
public: property String^ InnerXml { virtual String^ get() override; virtual void set(String^ value) override; }
| Exception | Condition |
|---|---|
| XmlException | The XML specified when setting this property is not well-formed. |
Setting this property replaces the children 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).
The following example compares the InnerText and InnerXml properties.
#using <System.Xml.dll> using namespace System; using namespace System::Xml; int main() { XmlDocument^ doc = gcnew XmlDocument; doc->LoadXml( "<root><elem>some text<child/>more text</elem></root>" ); XmlElement^ elem = dynamic_cast<XmlElement^>(doc->DocumentElement->FirstChild); // Note that InnerText does not include the markup. Console::WriteLine( "Display the InnerText of the element..." ); Console::WriteLine( elem->InnerText ); // InnerXml includes the markup of the element. Console::WriteLine( "Display the InnerXml of the element..." ); Console::WriteLine( elem->InnerXml ); // Set InnerText to a string that includes markup. // The markup is escaped. elem->InnerText = "Text containing <markup/> will have char(<) and char(>) escaped."; Console::WriteLine( elem->OuterXml ); // Set InnerXml to a string that includes markup. // The markup is not escaped. elem->InnerXml = "Text containing <markup/>."; Console::WriteLine( elem->OuterXml ); }
Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Available since 10
.NET Framework
Available since 1.1
Show: