C#XmlDocument输出字符串

XmlDocument xmlDoc = new XmlDocument();

//假定该xmlDoc已经有内容;

MemoryStream streamXml = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(streamXml, Encoding.UTF8);
writer.Formatting = Formatting.Indented;
xmlDoc.Save(writer);

StreamReader reader = new StreamReader(streamXml, Encoding.UTF8);
streamXml.Position = 0;
String content = reader.ReadToEnd();
reader.Close();
streamXml.Close();

Console.WriteLine(content);

C#XmlDocument输出字符串

上一篇:C#如何获取系统downloads和documents路径


下一篇:Windows下将FTP映射成一个盘