Write existing XML string, or XMLDocument, into a file

  • Thread starter Thread starter feng
  • Start date Start date
F

feng

I think I didn't phrase my quetion clear enough in the
last post. Here is what I need:

In my VB.Net code, I already have a XML created in
XMLDocument formate. I can also convert it into a string
using the innerXML property of the XMLDocument object.
What I want is to write this existing string, or
XMLDocument, into a file, for instance, c:\test.xml.

So as you can see, XMLWritter doesn't help me here,
because I am not creating an XML file tag by tag. All I
want is to write an EXISTING XML string into a file.

Please help!
 
Feng,
If you have an XMLDocument, you just save it to a file!

Dim doc As XmlDocument
doc.Save("myfile.xml")

Which as you can see is entirely different then trying to write a string
that may or may not have XML in it to a file.

Dim writer As New StreamWriter("myfile.xml")
writer.Write(theString)
writer.Close()

Hope this helps
Jay
 
Back
Top