PDA

Click to See Complete Forum and Search --> : Writing to New XML File Throws IOException


dafatdude
Jan 30th, 2006, 06:02 PM
Try
Dim loXmlWriter As New Xml.XmlTextWriter("\\My Documents\\mcsd.fclib", System.Text.Encoding.UTF8)

loXmlWriter.WriteStartDocument()
loXmlWriter.WriteStartElement("testlib")

loXmlWriter.WriteStartElement("info")
loXmlWriter.WriteAttributeString("name", "MCSD 70-306")
loXmlWriter.WriteEndElement()

loXmlWriter.WriteStartElement("questioncollection")
loXmlWriter.WriteStartElement("question")
loXmlWriter.WriteAttributeString("qtext", "What is the latest version of windows")
loXmlWriter.WriteAttributeString("atext", "Windows XP")
loXmlWriter.WriteEndElement()
loXmlWriter.WriteEndElement()

loXmlWriter.WriteEndElement()
loXmlWriter.WriteEndDocument()
loXmlWriter.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try


Hello all.

The above code throws an exception in the .NET framework when on the first line where it tries to write the file. What am i doing wrong, it can't be to compilcated but i can't for the life of me work it out.

Can someone help?

Also, if there is a better way to do this, please post :)

Thanks

Strider
Jan 31st, 2006, 04:19 AM
only need for one slash '/'

Dim loXmlWriter As New Xml.XmlTextWriter("\My Documents\mcsd.fclib", System.Text.Encoding.UTF8)