XmlWriter.WriteProcessingInstruction writes out a processing instruction
Option Strict
Option Explicit
Imports System
Imports System.IO
Imports System.Xml
Public Class Sample
Private Const filename As String = "sampledata.xml"
Public Shared Sub Main()
Dim settings As XmlWriterSettings = new XmlWriterSettings()
settings.Indent = true
Dim writer As XmlWriter = XmlWriter.Create(filename, settings)
Dim PItext As String = "type=""text/xsl"" href=""book.xsl"""
writer.WriteProcessingInstruction("xml-stylesheet", PItext)
writer.WriteDocType("book", Nothing, Nothing, "<!ENTITY h ""hardcover"">")
writer.WriteComment("sample XML")
writer.WriteStartElement("book")
writer.WriteAttributeString("genre", "Tech")
writer.WriteAttributeString("ISBN", "1-111111-014")
writer.WriteElementString("title", "C#")
writer.WriteStartElement("style")
writer.WriteEntityRef("h")
writer.WriteEndElement()
writer.WriteElementString("price", "9.9")
writer.WriteCData("data")
writer.WriteEndElement()
writer.WriteEndDocument()
writer.Flush()
writer.Close()
End Sub 'Main
End Class 'Sample
Related examples in the same category