Solved

using XMLTextWriter convert the xml tags to MemoryStream

Posted on 2004-09-01
4
550 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
egit plugin on eclipse 8 95
How to Convert a Quote to an Order in SalesForce 2 111
Object Oriented Programming, C#, referencing, scoping. 13 83
Survey branching tutorial 11 37
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?

685 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