XmlConvert class in VB.NET

In this article I will explain you how to read an XmlConvert Class in ADO.NET.
  • 2568

There are some characters that are not valid in XML documents. XML documents use XSD types, which are different than CLR (.NET) data types. The XmlConvert class contains methods to convert from CLR types to XSD types and vice versa. The DecodeName method transfers an XML name into an ADO.NET object such as DataTable. The EncodeName Method is the reverse of DecodeName: it converts an ADO.NET object to valid XSD name. It takes any invalid character and replaces it with an escape string. Another method, EncodeLocalNAme, converts unpermitted names to valid names.

Besides these three methods, the XmlConvert class has many methods to convert from a string object to Boolean. Byte, integer, and so on. Listing 6-15 shows the conversion from Boolean and Date Time object to XML values.

Listing 6-15 xml convert example

Imports System
Imports System.Xml

Class XmlReaderSamp
    Private Shared Sub Main(ByVal args As String())
        Dim writer As New XmlTextWriter("C:\Documents and Settings\PuranMAC\My Documents\Visual Studio 2008\Projects\ConsoleApplication2\ConsoleApplication2\XMLFile1.xml", Nothing)
        Dim b1 As Boolean = True
        writer.WriteElementString("TestBoolean", XmlConvert.ToString(b1))
        Dim dt As New DateTime(2000, 1, 1)
        writer.WriteElementString("test date", XmlConvert.ToString(dt))
    End Sub
End Class


Hope this article would have helped you in understanding XmlConvert Class in ADO.NET. See other articles on the website also for further reference.


More Articles

© 2020 DotNetHeaven. All rights reserved.