XmlTextReader.IsEmptyElement tells whether the current node is an empty element (for example, ). : XmlTextReader « XML « VB.Net






XmlTextReader.IsEmptyElement tells whether the current node is an empty element (for example, ).

 

Option Strict
Option Explicit

Imports System
Imports System.IO
Imports System.Xml

Public Class Sample

    Public Shared Sub Main()
            Dim reader As XmlTextReader = Nothing
            reader = New XmlTextReader("elems.xml")
            While reader.Read()
                If reader.IsStartElement() Then
                    If reader.IsEmptyElement Then
                        Console.WriteLine("<{0}/>", reader.Name)
                    Else
                        Console.Write("<{0}>" + " ", reader.Name)
                        reader.Read() 'Read the start tag.
                        If (reader.IsStartElement())  'Handle nested elements.
                          Console.WriteLine()
                          Console.Write("<{0}>", reader.Name)
                        End If
                        Console.WriteLine(reader.ReadString()) 'Read the text content of the element.
                    End If
                End If
            End While
    End Sub 
End Class 

   
  








Related examples in the same category

1.Create XmlTextReader class with the specified file.
2.Create XmlTextReader class with the specified TextReader.
3.XmlTextReader.AttributeCount gets the number of attributes on the current node.
4.XmlTextReader.BaseURI Property gets the base URI of the current node.
5.XmlTextReader.Depth Property gets the depth of the current node in the XML document.
6.XmlTextReader.GetAttribute gets the value of the attribute with the specified name.
7.XmlTextReader.GetRemainder gets the remainder of the buffered XML.
8.XmlTextReader.HasValue tells whether the current node can have a Value other than String.Empty.
9.XmlTextReader.LinePosition Property gets the current line position.
10.XmlTextReader.LocalName Property gets the local name of the current node.
11.XmlTextReader.MoveToFirstAttribute Method moves to the first attribute.
12.XmlTextReader.Name Property gets the qualified name of the current node.
13.XmlTextReader.Normalization Property tells whether to normalize white space and attribute values.
14.XmlTextReader.ReadBase64 Method decodes Base64 and returns the decoded binary bytes.
15.XmlTextReader.XmlLang Property gets the current xml:lang scope.
16.XmlTextReader.XmlSpace Property gets the current xml:space scope.
17.Read binary hex value