官方例子:https://msdn.microsoft.com/en-us/library/system.xml.xmlnode.outerxml.aspx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace outerXML
{
    class Program
    {
        static void Main(string[] args)
        {
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.LoadXml("<Elem><I>woaini</I><NI>ui</NI></Elem>");
            XmlNode root = xmldoc.DocumentElement;
            Console.WriteLine(root.OuterXml);

            Console.WriteLine(root.InnerXml);
            Console.ReadKey();
        }
    }
}

结果:

<Elem><I>woaini</I><NI>ui</NI></Elem>
<I>woaini</I><NI>ui</NI>

相关文章:

  • 2022-12-23
  • 2021-09-14
  • 2021-04-10
  • 2021-09-26
  • 2021-09-03
  • 2021-11-08
  • 2021-11-14
猜你喜欢
  • 2022-12-23
  • 2021-12-20
  • 2021-06-08
  • 2022-12-23
  • 2021-08-29
相关资源
相似解决方案