R
Random
Why, oh why, won't my XmlTextWriter write properly to the MemoryStream. Or,
why can't I read the xml back out of the MemoryStream! I can't think of a
thing....
Dim reader As XmlReader
Dim stream As MemoryStream = New MemoryStream()
Dim writer As XmlWriter = New XmlTextWriter(stream, Encoding.UTF8)
writer.WriteStartDocument(True)
writer.WriteStartElement("fooitems")
writer.WriteElementString("foo", "myfoo")
writer.WriteEndElement()
writer.WriteEndDocument()
reader = New XmlTextReader(stream)
writer.Close()
reader.MoveToContent()
reader.ReadOuterXml()
After I run this, I get a 'Root Element is missing' error. I can't see that
anything ever gets into the stream.
why can't I read the xml back out of the MemoryStream! I can't think of a
thing....
Dim reader As XmlReader
Dim stream As MemoryStream = New MemoryStream()
Dim writer As XmlWriter = New XmlTextWriter(stream, Encoding.UTF8)
writer.WriteStartDocument(True)
writer.WriteStartElement("fooitems")
writer.WriteElementString("foo", "myfoo")
writer.WriteEndElement()
writer.WriteEndDocument()
reader = New XmlTextReader(stream)
writer.Close()
reader.MoveToContent()
reader.ReadOuterXml()
After I run this, I get a 'Root Element is missing' error. I can't see that
anything ever gets into the stream.