Write existing XML string, or XMLDocument, into a file

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!
 
J

Jay B. Harlow [MVP - Outlook]

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
 

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