Mondeo
Well-known member
I have the following simple XML File called getvehicles.xml
<?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 code
Dim
file As String = Server.MapPath("getvehicles.xml")
Dim doc As New XmlDocument
doc.Load(file)
Dim NodeList As XmlNodeList
Dim GetVehiclesNode As XmlNode
NodeList = doc.GetElementsByTagName("GetVehicle")
For Each GetVehiclesNode In NodeList
Response.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
<?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 code
Dim
file As String = Server.MapPath("getvehicles.xml")
Dim doc As New XmlDocument
doc.Load(file)
Dim NodeList As XmlNodeList
Dim GetVehiclesNode As XmlNode
NodeList = doc.GetElementsByTagName("GetVehicle")
For Each GetVehiclesNode In NodeList
Response.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