Redigera

Dela via


XmlDocumentFragment.InnerXml Property

Definition

Gets or sets the markup representing the children of this node.

public:
 virtual property System::String ^ InnerXml { System::String ^ get(); void set(System::String ^ value); };
public override string InnerXml { get; set; }
member this.InnerXml : string with get, set
Public Overrides Property InnerXml As String

Property Value

The markup of the children of this node.

Exceptions

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

Examples

The following example uses the InnerXml property to set the contents of the document fragment.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   
   // Create the XmlDocument.
   XmlDocument^ doc = gcnew XmlDocument;
   
   // Create a document fragment.
   XmlDocumentFragment^ docFrag = doc->CreateDocumentFragment();
   
   // Set the contents of the document fragment.
   docFrag->InnerXml = "<item>widget</item>";
   
   // Display the document fragment.
   Console::WriteLine( docFrag->InnerXml );
}
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {
    // Create the XmlDocument.
    XmlDocument doc = new XmlDocument();

    // Create a document fragment.
    XmlDocumentFragment docFrag = doc.CreateDocumentFragment();

    // Set the contents of the document fragment.
    docFrag.InnerXml ="<item>widget</item>";

    // Display the document fragment.
    Console.WriteLine(docFrag.InnerXml);
  }
}
Option Explicit
Option Strict

Imports System.IO
Imports System.Xml

Public Class Sample
    
    Public Shared Sub Main()
        ' Create the XmlDocument.
        Dim doc As New XmlDocument()
        
        ' Create a document fragment.
        Dim docFrag As XmlDocumentFragment = doc.CreateDocumentFragment()
        
        ' Set the contents of the document fragment.
        docFrag.InnerXml = "<item>widget</item>"
        
        ' Display the document fragment.
        Console.WriteLine(docFrag.InnerXml)
    End Sub
End Class

Remarks

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

Applies to