Solved

using XMLTextWriter convert the xml tags to MemoryStream

Posted on 2004-09-01
4
545 Views
Last Modified: 2010-05-18
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,
0
Comment
Question by:Rajkumar_G
4 Comments
 
LVL 3

Accepted Solution

by:
vippx earned 200 total points
ID: 11952678
Put a xtw.flush() wherever u need the XMLTextWriter to flush the generated XML to the memory stream.
0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12016945
put xtw.flush() before xtw.close()
using ms before xtw.close()
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now