XmlTextWriter.WriteQualifiedName Method writes out the namespace-qualified name : XmlTextWriter « XML « VB.Net






XmlTextWriter.WriteQualifiedName Method writes out the namespace-qualified name

 

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.WriteStartElement("schema")

        writer.WriteAttributeString("xmlns", Nothing, "http://www.w3.org/2001/XMLSchema")
        writer.WriteAttributeString("xmlns", "po", Nothing, "http://domain.com/po")

        writer.WriteStartElement("element")

        writer.WriteAttributeString("name", "purchaseOrder")

        writer.WriteStartAttribute(Nothing, "type", Nothing)
        writer.WriteQualifiedName("data", "http://domain.com/po")
        writer.WriteEndAttribute()

        writer.WriteEndElement()

        writer.WriteEndElement()

        writer.Flush()
        writer.Close()

        Dim doc As New XmlDocument()

        doc.PreserveWhitespace = True
        doc.Load(filename)
        Console.Write(doc.InnerXml)
    End Sub 
End Class

   
  








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.WriteCData writes out a block
6.XmlTextWriter.WriteCharEntity Method forces the generation of a character entity for the specified Unicode character value.
7.XmlTextWriter.WriteEndElement closes one element and pops the corresponding namespace scope.
8.XmlTextWriter.WriteFullEndElement closes one element and pops the corresponding namespace scope.
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.