Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing to a file with XMLTextWriter

Status
Not open for further replies.
Mar 1, 2001
37
US
I'm having trouble writing to a file using the XMLTextWriter. I have to trouble writing to the Console but can't get it to a file. Here is a sample.

Private Sub WriteXML()

Dim filename = "c:\temp\response.txt"
'Dim writer As New XmlTextWriter(Console.Out) 'this works
Dim writer As New XmlTextWriter(filename) 'this doesn't

writer.Formatting = Formatting.Indented
writeQuote(writer)
writer.Close()
End Sub

Any idea why it doesn't work when I use filename? Thanks.

 
I got it to work. Here's the solution, hope it helps others out.

Private Sub WriteXML()

Dim filename As String = "c:\temp\response.xml"
Dim i As Integer = FreeFile()

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


writer.Formatting = Formatting.Indented
WriteQuote(writer)
writer.Close()
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top