Use XMLTextReader to read the data in an XML file (VB.net) : XMLTextReader « XML « ASP.NET Tutorial






<%@ Page Language="VB" %>
<%@ Import Namespace="System.Xml" %>

<script runat=server>
   sub Page_Load(Sender as Object, e as EventArgs)
      dim reader as XMLTextReader
         
      try
         reader = new XMLTextReader(Server.MapPath("Data.xml"))
         While reader.Read()
            Response.Write("<b>" & reader.Name & "</b> " & _
                reader.Value & "<br>")
         
         End While
      catch ex as Exception
         Response.Write("Error accessing XML file")
      finally
         reader.close
      end try
   end sub
</script>

<html><body>

</body></html>

File: Data.xml

<?xml version="1.0"?>
<bookstore>
  <book genre="asdf">
    <title>asdf</title>
    <author>
      <first-name>asdf</first-name>
      <last-name>asdf</last-name>
    </author>
    <price>asdf</price>
  </book>
  <book genre="asdf">
    <title>asdf</title>
    <author>
      <first-name>asdf</first-name>
      <last-name>asdf</last-name>
    </author>
    <price>asdf</price>
  </book>
  <book genre="asdf">
    <title>asdf</title>
    <author>
      <first-name>asdf</first-name>
      <last-name>asdf</last-name>
    </author>
    <price>asdf</price>
  </book>
</bookstore>








25.15.XMLTextReader
25.15.1.Use XMLTextReader to read the data in an XML file (VB.net)
25.15.2.Fill XML data into StringBuilder from XmlTextReader
25.15.3.Read xml and build page along with it