Verifies name according to the W3C Extended Markup Language recommendation. : XmlTextWriter « XML « VB.Net






Verifies name according to the W3C Extended Markup Language recommendation.

  

Imports System
Imports System.Xml

Public Class Sample

  Public Shared Sub Main()
     Dim writer as XmlTextWriter = new XmlTextWriter ("out.xml", nothing)
     Dim tag as string = "item name"

    try
     writer.WriteStartElement("root")
     writer.WriteStartElement(XmlConvert.VerifyName(tag))
     catch e as XmlException
        Console.WriteLine(e.Message)
        writer.WriteStartElement(XmlConvert.EncodeName(tag))
     end try

     writer.WriteString("hammer")
     writer.WriteEndElement()
     writer.WriteEndElement()
     writer.Close()

  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.WriteQualifiedName Method writes out the namespace-qualified name
10.XmlTextWriter.WriteRaw Method writes raw markup manually from a string.
11.XmlTextWriter.WriteWhitespace writes out the given white space.