Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

using XMLTextWriter convert the xml tags to MemoryStream

Posted on 2004-09-01
4
548 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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
firstswap challenge 20 82
parse convert xml feed to text (python) 2 90
C# code editing and collaboration 3 131
Delphi: barcode reading on android platform 1 51
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.

808 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