Hi, I'm trying to create an XML document with XMLTextWriter but I want to store it in memory (not write it to a file like so many examples do). I tried the following but with no luck. Should I not user this object for this purpose? Thanks, Dave
MemoryStream stm = new MemoryStream()
XmlTextWriter writer = new XmlTextWriter(stm, System.Text.Encoding.UTF8)
writer.WriteStartDocument()
writer.WriteComment("This Is A List of My Books")
writer.WriteStartElement("MyBooks")
writer.WriteStartElement("Book")
writer.WriteAttributeString("ISBN", "1861005652")
writer.WriteAttributeString("Title", "Professional Visual Basic Interoperability")
writer.WriteElementString("Author", "Billy Hollis")
writer.WriteElementString("Author", "Rockford Lhotka")
writer.WriteEndElement()
writer.WriteEndElement()
writer.WriteEndDocument()
XmlTextReader xr = new XmlTextReader(stm)
XmlDocument xmldoc = new XmlDocument()
xmldoc.Load(xr)
But get...
The root element is missing