XmlNode.InnerText XmlNode.InnerText XmlNode.InnerText XmlNode.InnerText Property

정의

노드와 모든 자식 노드의 연결된 값을 가져오거나 설정합니다.Gets or sets the concatenated values of the node and all its child nodes.

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

속성 값

노드와 모든 자식 노드의 연결된 값입니다.The concatenated values of the node and all its child nodes.

예제

다음 예제에서는 비교 합니다 InnerTextInnerXml 속성입니다.The following example compares the InnerText and InnerXml properties.

#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>" );
   XmlNode^ elem = 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;
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>");

    XmlNode elem = 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 );
  }
}
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 XmlNode = 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 )
    
  end sub
end class

출력:Output:

Display the InnerText of the element...  
some textmore text  
Display the InnerXml of the element...  
some text<child />more text  
<elem>Text containing &lt;markup/&gt; will have char(&lt;) and char(&gt;) escape  
d.</elem>  
<elem>Text containing <markup />.</elem>  

설명

이 속성을 설정 자식 노드를 모두 지정된 된 문자열의 구문 분석 된 내용으로 바뀝니다.Setting this property replaces all the child nodes with the parsed contents of the given string.

리프 노드에 대 한 InnerText 와 동일한 콘텐츠를 반환 합니다 Value 속성입니다.For leaf nodes, InnerText returns the same content as the Value property.

이 속성은 DOM(문서 개체 모델)에 대한 Microsoft 확장입니다.This property is a Microsoft extension to the Document Object Model (DOM).

적용 대상