首页 > 代码库 > xmlWriter

xmlWriter

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 = 0; // 重置流的位置,以便我们可以从头读取XmlReader xmlReader = XmlReader.Create(msXml);