xmlWriter

时间:2021-11-05 01:49:10
MemoryStream msXml = new MemoryStream();
XmlTextWriter xmlWriter = new XmlTextWriter(msXml, Encoding.UTF8);
xmlWriter.WriteStartElement("rss");
xmlWriter.WriteAttributeString("version", "2.0");
xmlWriter.WriteStartElement("channel");
xmlWriter.WriteElementString("title", "Test");
xmlWriter.WriteEndElement();
xmlWriter.WriteEndElement();
xmlWriter.Flush(); // 确保书写器更新到Stream中
msXml.Position = ; // 重置流的位置,以便我们可以从头读取
XmlReader xmlReader = XmlReader.Create(msXml);