Hi
I use this code to write an xml file....
<code>
Sub Page_Load()
' initialize a XmlTextWriter object
Dim objXmlWriter As XmlTextWriter = Nothing
' location to the XML file to write
Dim strXmlFile As [String] = Server.MapPath("testfile.xml")
objXmlWriter = New XmlTextWriter(strXmlFile, Nothing)
' start writing the XML document
objXmlWriter.WriteStartDocument(False)
' start with the root element
objXmlWriter.WriteStartElement("library" & vbCrlf)
' first child element
objXmlWriter.WriteStartElement("book", Nothing)
' add an attribute
objXmlWriter.WriteAttributeString("bkid", "MF01")
' some text
objXmlWriter.WriteElementString("title", "XML and ASP")
' back to the root element
' closing each element written above
' one at a time
objXmlWriter.WriteEndElement()
objXmlWriter.WriteEndElement()
' flush the object and write the
' XML data to the file
objXmlWriter.Flush()
' Close the XMLWriter object
If Not (objXmlWriter Is Nothing) Then
objXmlWriter.Close()
End If
End Sub 'Page_Load
</code>
But everything is written as one line, how can get the different elements on seperate lines?
Regards
M
I use this code to write an xml file....
<code>
Sub Page_Load()
' initialize a XmlTextWriter object
Dim objXmlWriter As XmlTextWriter = Nothing
' location to the XML file to write
Dim strXmlFile As [String] = Server.MapPath("testfile.xml")
objXmlWriter = New XmlTextWriter(strXmlFile, Nothing)
' start writing the XML document
objXmlWriter.WriteStartDocument(False)
' start with the root element
objXmlWriter.WriteStartElement("library" & vbCrlf)
' first child element
objXmlWriter.WriteStartElement("book", Nothing)
' add an attribute
objXmlWriter.WriteAttributeString("bkid", "MF01")
' some text
objXmlWriter.WriteElementString("title", "XML and ASP")
' back to the root element
' closing each element written above
' one at a time
objXmlWriter.WriteEndElement()
objXmlWriter.WriteEndElement()
' flush the object and write the
' XML data to the file
objXmlWriter.Flush()
' Close the XMLWriter object
If Not (objXmlWriter Is Nothing) Then
objXmlWriter.Close()
End If
End Sub 'Page_Load
</code>
But everything is written as one line, how can get the different elements on seperate lines?
Regards
M