XmlDocumentFragment.InnerXml Właściwość

Definicja

Pobiera lub ustawia znaczniki reprezentujące elementy podrzędne tego węzła.

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

Wartość właściwości

String

Znaczniki elementów podrzędnych tego węzła.

Wyjątki

Kod XML określony podczas ustawiania tej właściwości nie jest poprawnie sformułowany.

Przykłady

W poniższym przykładzie użyto właściwości InnerXml, aby ustawić zawartość fragmentu dokumentu.

#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

Uwagi

Ustawienie tej właściwości zastępuje elementy podrzędne węzła zawartością przeanalizowanego danego ciągu. Analizowanie odbywa się w bieżącym kontekście przestrzeni nazw.

Ta właściwość jest rozszerzeniem firmy Microsoft do modelu obiektów dokumentów (DOM).

Dotyczy