How to read XML

MondeoST24

Member
Joined
Mar 9, 2006
Messages
16
Programming Experience
Beginner
I have the following simple XML File called getvehicles.xml
HTML:
-?xml version="1.0" encoding="utf-8" ?--GetVehicles release="8.1" environment="Production" lang="en-US"--ApplicationArea--/ApplicationArea--DataArea--Error--/Error--Vehicles--Vehicle--Combined_Make>VOLVO-/Combined_Make--Combined_Model>70 SERIES C70 T5 GT-/Combined_Model--/Vehicle--/Vehicles--/DataArea--/GetVehicles-
I need to read the combined _make and combined_model tags. I have this codeDim file As String = Server.MapPath("getvehicles.xml")Dim doc As New XmlDocumentdoc.Load(file)Dim NodeList As XmlNodeListDim GetVehiclesNode As XmlNodeNodeList = doc.GetElementsByTagName("GetVehicle")For Each GetVehiclesNode In NodeListResponse.Write(GetVehiclesNode.Attributes("Combined_Make").InnerText)Response.Write(GetVehiclesNode.Attributes("Combined_Model").InnerText)Next But this returns an object not set to instance of an object error. What is the correct code.Many thanks, this is my first try with XML
 
use the [ html ] code tag or appropriate button on advanced post editor. xml works basically as html tags. you can edit the original request to fix this. I see you have used the html code box, but the posted text was obviously not recognized as this. I have never had any problem with with posting html/xml. open the xml file in notepad or visual studio, copy the text, paste it into the html box. copying from what internet explorer displays in browser window is no good because it puts '-' and '+' and all kinds of text formatting into it.

Also use the regular [ code ] box or appropriate button in advanced post editor when posting regular vb.net code.
 
Back
Top