编程语言
首页 > 编程语言> > C#XmlDocument输出字符串

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);

标签:writer,C#,streamXml,XmlDocument,reader,字符串,new,xmlDoc
来源: https://www.cnblogs.com/LCLBook/p/11002707.html