【发布时间】:2019-06-02 15:41:04
【问题描述】:
考虑以下创建 XML 文档并显示它的简单代码。
XmlDocument xml = new XmlDocument();
XmlElement root = xml.CreateElement("root");
xml.AppendChild(root);
XmlComment comment = xml.CreateComment("Comment");
root.AppendChild(comment);
textBox1.Text = xml.OuterXml;
它按预期显示:
<root><!--Comment--></root>
但是,它不显示
<?xml version="1.0" encoding="UTF-8"?>
那么我怎样才能得到它呢?
【问题讨论】:
标签: c# .net xml xmldocument