Data Access Advice

  • Thread starter Thread starter Ben
  • Start date Start date
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
 
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
 
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.
 
Back
Top