XmlElement.InnerXml プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
このノードの子だけを表すマークアップを取得または設定します。
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
プロパティ値
このノードの子のマークアップ。
例外
このプロパティの設定時に指定される XML は、整形式ではありません。
例
次の例では、プロパティと比較InnerXml
しますInnerText。
#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 );
}
// This example produces the following results:
//
// Display the InnerText of the element...
// some textmore text
// Display the InnerXml of the element...
// some text<child />more text
// <elem>Text containing <markup/> will have char(<) and char(>) escaped.</elem>
// <elem>Text containing <markup />.</elem>
using System;
using System.Xml;
public class Test {
public static void Main() {
XmlDocument doc = new XmlDocument();
doc.LoadXml("<root>"+
"<elem>some text<child/>more text</elem>" +
"</root>");
XmlElement elem = (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 );
}
}
// This example produces the following results:
//
// Display the InnerText of the element...
// some textmore text
// Display the InnerXml of the element...
// some text<child />more text
// <elem>Text containing <markup/> will have char(<) and char(>) escaped.</elem>
// <elem>Text containing <markup />.</elem>
Imports System.Xml
public class Test
public shared sub Main()
Dim doc as XmlDocument = new XmlDocument()
doc.LoadXml("<root>"& _
"<elem>some text<child/>more text</elem>" & _
"</root>")
Dim elem as XmlElement
elem = CType (doc.DocumentElement.ChildNodes.Item(0), XmlElement)
' 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 )
end sub
end class
' This example produces the following results:
'
' Display the InnerText of the element...
' some textmore text
' Display the InnerXml of the element...
' some text<child />more text
' <elem>Text containing <markup/> will have char(<) and char(>) escaped.</elem>
' <elem>Text containing <markup />.</elem>
注釈
このプロパティを設定すると、ノードの子が、指定された文字列の解析された内容に置き換えられます。 文字列の解析は、現在の名前空間コンテキストで実行されます。
このプロパティは、ドキュメント オブジェクト モデル (DOM) の Microsoft 拡張機能です。