The XmlWriter class contains the functionality to write to XML documents. It is an abstract base class used through XmlTextWriter and XmlNodeWriter classes. It contains methods and properties to write to XML documents.
' Import System.Xml namespace Imports System.Xml Module Module1 Sub Main() ' Create a new file in C:\\ dir Dim textWriter As XmlTextWriter = New XmlTextWriter("C:\\myXmFile.xml", Nothing) ' Opens the document textWriter.WriteStartDocument() ' Write comments textWriter.WriteComment("First Comment XmlTextWriter Sample Example(")")textWriter.WriteComment("myXmlFile.xml in root dir") ' Write first element textWriter.WriteStartElement("Student") textWriter.WriteStartElement("r", "RECORD", "urn:record") ' Write next element textWriter.WriteStartElement("Name", "") textWriter.WriteString("Student") textWriter.WriteEndElement() ' Write one more element textWriter.WriteStartElement("Address", "") textWriter.WriteString("Colony") textWriter.WriteEndElement() ' WriteChars textWriter.WriteStartElement("Char") Dim ch() As Char = {"b", "l", "last"} textWriter.WriteChars(ch, 0, ch.Length) textWriter.WriteEndElement() ' Ends the document. textWriter.WriteEndDocument() ' close writer textWriter.Close() End Sub End Module
|
No responses found. Be the first to respond and make money from revenue sharing program.
|