Hello,
I want to read the XML file using VB.NET. This XML file contains tags which are nested multi level. Following is the listing of my code to read the XML file.
I am not able to retrieve the value of auth-title tag.
Dim reader As XmlTextReader = New XmlTextReader("D:\Project\ReadXMLTest\Books1.xml")
reader.WhitespaceHandling = WhitespaceHandling.None
Dim a1 As New ArrayList
Dim Title As String
Dim firstName As String
Dim lastName As String
Dim authTitle As String
Dim Price As Double
reader.ReadStartElement()
While Not reader.LocalName.Equals("bookstore")
reader.Read()
While Not reader.LocalName.Equals("book")
Dim elementName As String = reader.LocalName
'reader.Read()
Dim data As String = reader.ReadString
If elementName.Equals("title") Then
Title = data
Response.Write(Title & "
")
End If
If elementName.Equals("auth-title") Then
authTitle = data
Response.Write(authTitle & "
")
End If
If elementName.Equals("first-name") Then
firstName = data
Response.Write(firstName & "
")
End If
If elementName.Equals("last-name") Then
lastName = data
Response.Write(lastName & "
")
End If
If elementName.Equals("price") Then
Price = data
Response.Write(Price & "
")
End If
reader.Read()
End While
reader.Read()
End While
Following is the XML file
ASP.NET Unleashed
Mr.
Hitesh
Kapadia
8.99
VB.NET Unleashed
Mr.
Jay
Kakar
11.99
Crystal Reports
Mr.
Vijay
Chandra
9.99