Mega Code Archive

 
Categories / VB.Net / XML
 

XmlTextReader HasValue tells whether the current node can have a Value other than String Empty

Imports System Imports System.IO Imports System.Xml Public Class Sample     Public Shared Sub Main()         Dim reader As XmlTextReader = Nothing         Try             reader = New XmlTextReader("book1.xml")             reader.WhitespaceHandling = WhitespaceHandling.None             While reader.Read()                 If reader.HasValue Then                     Console.WriteLine("({0})  {1}={2}", reader.NodeType, reader.Name, reader.Value)                 Else                     Console.WriteLine("({0}) {1}", reader.NodeType, reader.Name)                 End If             End While         Finally             If Not (reader Is Nothing) Then                 reader.Close()             End If         End Try     End Sub End Class