我使用一种XmlDocument.WriteTo(XmlWriter)方法将 an 序列化为XmlDocument文本文件。我也尝试过XmlDocument.OuterXml。两者都输出单行 XML 文本,人类很难阅读(对于相当大的 XML 文档来说甚至是不可能的)。
有没有办法输出格式良好、人类可读的 XML 文本?我的意思是每个元素都从新行开始,并使用缩进来可视化层次结构级别。
小智 6
我同意 BoltClock。这是示例代码-
//Create a writer to write XML to the console.
XmlTextWriter writer = null;
writer = new XmlTextWriter (Console.Out);
//Use indentation for readability.
writer.Formatting = Formatting.Indented;
writer.Indentation = 4;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4728 次 |
| 最近记录: |