zoukankan      html  css  js  c++  java
  • [C#]格式化XmlDocument

     1string s = “<Test><a></a></Test>”;
     2System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
     3doc.LoadXml(s);
     4System.IO.MemoryStream ms = new System.IO.MemoryStream();
     5System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(ms, Encoding.UTF8);
     6xmlWriter.Indentation = 4;
     7xmlWriter.Formatting = System.Xml.Formatting.Indented;
     8doc.WriteContentTo(xmlWriter);
     9xmlWriter.Close();
    10string result = Encoding.UTF8.GetString(ms.ToArray());
  • 相关阅读:
    Nginx
    Influxdb
    Gitlab
    Git
    Gogs
    Dockerfile
    Docker Data
    My Projects
    中文学习
    科技精选
  • 原文地址:https://www.cnblogs.com/jinweijie/p/1229461.html
Copyright © 2011-2022 走看看