Home All Groups Group Topic Archive Search About
Author
26 Sep 2006 9:52 PM
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

Author
27 Sep 2006 7:27 AM
Stephany Young
Show quote Hide quote
"Ben" <B**@Newsgroups.microsoft.com> wrote in message
news:ucYl1Yb4GHA.696@TK2MSFTNGP06.phx.gbl...
> 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
>
Author
27 Sep 2006 7:33 AM
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.


Show quoteHide quote
"Ben" <B**@Newsgroups.microsoft.com> wrote in message
news:ucYl1Yb4GHA.696@TK2MSFTNGP06.phx.gbl...
> 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
>