XmlDocumentFragment.InnerXml Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應