XmlTextWriter.WriteCData writes out a block : XmlTextWriter « XML « VB.Net






XmlTextWriter.WriteCData writes out a block

 

Option Explicit
Option Strict

Imports System
Imports System.IO
Imports System.Xml

Public Class Sample
    Private Shared filename As String = "sampledata.xml"
    Public Shared Sub Main()
        Dim writer As XmlTextWriter = Nothing

        writer = New XmlTextWriter(filename, Nothing)
        writer.Formatting = Formatting.Indented

        writer.WriteStartDocument()

        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", "Programming")
        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("Prices 15% off!!")

        writer.WriteEndElement()
        writer.WriteEndDocument()

        writer.Flush()
        writer.Close()

        Dim doc As New XmlDocument()
        doc.PreserveWhitespace = True
        doc.Load(filename)
        Console.Write(doc.InnerXml)
    End Sub 'Main 
End Class 'Sample

   
  








Related examples in the same category

1.XmlTextWriter.Close closes this stream and the underlying stream.
2.XmlTextWriter.Flush
3.XmlTextWriter.Formatting Property indicates how the output is formatted.
4.XmlTextWriter.Indentation
5.XmlTextWriter.WriteCharEntity Method forces the generation of a character entity for the specified Unicode character value.
6.XmlTextWriter.WriteEndElement closes one element and pops the corresponding namespace scope.
7.XmlTextWriter.WriteFullEndElement closes one element and pops the corresponding namespace scope.
8.XmlTextWriter.WriteQualifiedName Method writes out the namespace-qualified name
9.XmlTextWriter.WriteRaw Method writes raw markup manually from a string.
10.XmlTextWriter.WriteWhitespace writes out the given white space.
11.Verifies name according to the W3C Extended Markup Language recommendation.