Data Access Advice

B

Ben

Hi

I need to post xml data to a url, I have have created an xml file using an
xml text writer as below but would rather a faster method that does not
involve writing the file to disk but using it from memory instead. Could
anyone suggest a method that is similar in coding (so as not to require too
many code changes).

Dim writer As New System.Xml.XmlTextWriter("c:\temp\TestXml.xml",
System.Text.Encoding.UTF8)

..Formatting = Xml.Formatting.Indented

..Indentation = 1

..IndentChar = ControlChars.Tab

..WriteStartDocument()

..WriteStartElement("........

Thanks
B
 
S

Stephany Young

Ben said:
Hi

I need to post xml data to a url, I have have created an xml file using an
xml text writer as below but would rather a faster method that does not
involve writing the file to disk but using it from memory instead. Could
anyone suggest a method that is similar in coding (so as not to require
too many code changes).

Dim writer As New System.Xml.XmlTextWriter("c:\temp\TestXml.xml",
System.Text.Encoding.UTF8)

.Formatting = Xml.Formatting.Indented

.Indentation = 1

.IndentChar = ControlChars.Tab

.WriteStartDocument()

.WriteStartElement("........

Thanks
B
 
S

Stephany Young

Instead of backing your XmlTextWriter with a disk file, back it with some
form of Stream object.

I tend to use a StringWriter.

"""ONE""" way of using it could be:

Dim _sw As New StringWriter

Dim writer As New System.Xml.XmlTextWriter(_sw, System.Text.Encoding.UTF8)

... Do your stuff here

_sw.Close

... Post the result of _sw.ToString to the url.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top