XmlNodeReader.ReadInnerXml Method

Namespace: System.Xml
Assembly: System.Xml.dll

Syntax

public override string ReadInnerXml();

Remarks

The ReadInnerXml method returns the inner markup of the current node. It includes all child nodes and their markup, but not the markup for the current node itself.

If the current node does not have any children, ReadInnerXml returns an empty string.

This method is useful when you want to extract the content of an XML element without including the element's tags.

Example

C# Example

using namespace System::Xml;

public ref class Example
{
    static void Main()
    {
        string xml = "<root><element attribute='value'>Content</element></root>";
        XmlReader reader = XmlReader::Create(new StringReader(xml));

        reader.ReadToFollowing("element");

        // Read the inner XML of the 'element' node
        string innerXml = reader.ReadInnerXml();

        Console::WriteLine("Inner XML of element: " + innerXml);
        // Output: Inner XML of element: Content

        reader.Close();
    }
};

See Also

Note: This documentation is for historical reference and may not reflect the latest API changes.