Create XmlTextReader class with the specified TextReader. : XmlTextReader « XML « VB.Net






Create XmlTextReader class with the specified TextReader.

 

Imports System
Imports System.IO
Imports System.Xml

public class Sample 

  public shared sub Main()

    Dim xmlData as string 
    xmlData = "<book>" & _
              "  <title>C#</title>" & _
              "  <price>5.95</price>" & _
              "</book>"

    Dim reader as XmlTextReader = new XmlTextReader(new StringReader(xmlData))
    reader.WhitespaceHandling = WhitespaceHandling.None

    while reader.Read()
       select case reader.NodeType
         case XmlNodeType.Element
           Console.Write("<{0}>", reader.Name)
         case XmlNodeType.Text
           Console.Write(reader.Value)
         case XmlNodeType.EndElement
           Console.Write("</{0}>", reader.Name)
       end select       
    end while           
    reader.Close()       
  end sub
end class

   
  








Related examples in the same category

1.Create XmlTextReader class with the specified file.
2.XmlTextReader.AttributeCount gets the number of attributes on the current node.
3.XmlTextReader.BaseURI Property gets the base URI of the current node.
4.XmlTextReader.Depth Property gets the depth of the current node in the XML document.
5.XmlTextReader.GetAttribute gets the value of the attribute with the specified name.
6.XmlTextReader.GetRemainder gets the remainder of the buffered XML.
7.XmlTextReader.HasValue tells whether the current node can have a Value other than String.Empty.
8.XmlTextReader.IsEmptyElement tells whether the current node is an empty element (for example, ).
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