XmlNode.InnerText 属性   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置节点及其所有子节点的串连值。
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
	属性值
节点及其所有子节点的串连值。
示例
以下示例比较 InnerText 和 InnerXml 属性。
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.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
输出:
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(>) escape
d.</elem>
<elem>Text containing <markup/>.</elem>
	注解
设置此属性会将所有子节点替换为给定字符串的已分析内容。
对于叶节点, InnerText 返回与 属性相同的内容 Value 。
此属性是文档对象模型 (DOM) 的 Microsoft 扩展。