zoukankan      html  css  js  c++  java
  • [dotNet Tip]XmlNode

    Attention to its rich propertes to read back a XmlNode's content:

    XmlNode.InnerText: escape all markup and just return the text.

    XmlNode.InnerXML

    XmlNode.OuterXML

    MSDN example this:

    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 );
    }
    }
     

  • 相关阅读:
    安卓第四周作业
    安卓作业。
    JSP第七周作业
    jsp第六周作业
    JSP第四周作业
    JSP第二次
    软件测试课堂练习
    JSP第一次
    Android页面
    Android作业
  • 原文地址:https://www.cnblogs.com/taoxu0903/p/1788972.html
Copyright © 2011-2022 走看看