Link to home
Start Free TrialLog in
Avatar of Rajkumar_G
Rajkumar_G

asked on

using XMLTextWriter convert the xml tags to MemoryStream

I have the following code windows application

Dim ms As MemoryStream
ms = New MemoryStream

Dim xtw As New Xml.XmlTextWriter(ms, System.Text.Encoding.UTF8)

xtw.Formatting = Formatting.Indented
xtw.Indentation = 2
xtw.QuoteChar = """"c
xtw.WriteStartDocument(True)
xtw.WriteComment("Data from CSI")
xtw.WriteStartElement("Data")
xtw.WriteStartElement("Employee")
xtw.WriteElementString("LastName", "Dillan")
xtw.WriteElementString("FirstName", "Bob")
xtw.WriteElementString("MiddleInitial", "E")
xtw.WriteEndElement()
xtw.WriteEndDocument()
xtw.Close()

I am using XMLTextWriter to fill the MemoryStream. What appears to be
happening is that the memory stream is getting filled. If I step through
this code and look at the length of (ms.length), it is always 0 (zero).

What am I missing? Any and all help is greatly appreciated.

--
Thanks,
ASKER CERTIFIED SOLUTION
Avatar of vippx
vippx

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
put xtw.flush() before xtw.close()
using ms before xtw.close()