XmlElement.InnerXml 속성
이 노드의 자식을 나타내는 태그를 가져오거나 설정합니다.
네임스페이스: System.Xml
어셈블리: System.Xml(system.xml.dll)
구문
‘선언
Public Overrides Property InnerXml As String
‘사용 방법
Dim instance As XmlElement
Dim value As String
value = instance.InnerXml
instance.InnerXml = value
public override string InnerXml { get; set; }
public:
virtual property String^ InnerXml {
String^ get () override;
void set (String^ value) override;
}
/** @property */
public String get_InnerXml ()
/** @property */
public void set_InnerXml (String value)
public override function get InnerXml () : String
public override function set InnerXml (value : String)
속성 값
이 노드의 자식을 나타내는 태그입니다.
예외
예외 형식 | 조건 |
---|---|
이 속성을 설정할 때 지정한 XML이 제대로 구성되지 않은 경우 |
설명
이 속성을 설정하면 노드의 자식이 특정 문자열의 구문 분석된 내용으로 바뀝니다. 구문 분석은 현재의 네임스페이스 컨텍스트에서 이루어집니다.
이 속성은 DOM(문서 개체 모델)에 대한 Microsoft 확장입니다.
예제
다음 예제에서는 InnerText 속성과 InnerXml 속성을 비교합니다.
Imports System
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
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 );
}
}
#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 );
}
import System.*;
import System.Xml.*;
public class Test
{
public static void main(String[] args)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<root>"
+ "<elem>some text<child/>more text</elem>"
+ "</root>");
XmlElement elem =
(XmlElement)doc.get_DocumentElement().get_FirstChild();
// Note that InnerText does not include the markup.
Console.WriteLine("Display the InnerText of the element...");
Console.WriteLine(elem.get_InnerText());
// InnerXml includes the markup of the element.
Console.WriteLine("Display the InnerXml of the element...");
Console.WriteLine(elem.get_InnerXml());
// Set InnerText to a string that includes markup.
// The markup is escaped.
elem.set_InnerText("Text containing <markup/> will have "
+ "char(<) and char(>) escaped.");
Console.WriteLine(elem.get_OuterXml());
// Set InnerXml to a string that includes markup.
// The markup is not escaped.
elem.set_InnerXml("Text containing <markup/>.");
Console.WriteLine(elem.get_OuterXml());
} //main
} //Test
플랫폼
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
2.0, 1.1, 1.0에서 지원
.NET Compact Framework
2.0, 1.0에서 지원