Use XmlWriter to generate XML document : XML File Creation « XML « VB.Net






Use XmlWriter to generate XML document

Use XmlWriter to generate XML document
 
Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO


Public Class MainClass

   Public Shared Sub Main()
        Dim myXmlSettings As New XmlWriterSettings
        myXmlSettings.Indent = True
        myXmlSettings.NewLineOnAttributes = True

        Using ProductWriter As XmlWriter = XmlWriter.Create("test.xml", myXmlSettings)

            ProductWriter.WriteComment("www.java2s.com ")
            ProductWriter.WriteStartElement("Product")
            ProductWriter.WriteAttributeString("Id", "101")
            ProductWriter.WriteAttributeString("COunt", "10")
            ProductWriter.WriteElementString("P1", "P2")
            ProductWriter.WriteEndElement() 

        End Using

   End Sub
End Class



           
         
  








Related examples in the same category

1.Create XML document: XmlDocument, XmlAttribute, XmlElement
2.Build an XML DocumentBuild an XML Document
3.Read and write XML with XmlReader and XmlWriter
4.Output with XmlWriter
5.Creating Xml with XmlTextWriter