How to bind to external xml source
Hi,
I have the following external XML file
http://www.autolocate.co.uk/usedcar/...540&output=xml
What I want to do is bind the values in the "ManCode" section to a drop down list. i.e. the vehicle makes. My code is as follows
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Populate "make" drop down from xml document
If Not Page.IsPostBack Then
Dim MakeDataSet As New DataSet()
MakeDataSet.ReadXml("http://www.autolocate.co.uk/usedcar/search/lifestyle.asp?dealersubscriberid=100540&output=xml")
DropDownList1.DataSource = MakeDataSet
DropDownList1.DataValueField = "value"
DropDownList1.DataTextField = "text"
DropDownList1.DataBind()
End If
End Sub
This throws an exception. I realise its something to do with multiple value+text pairs within different <parameter> tags. This is my first go with XML and not sure how to do it.
(external xml file follows)
Thanks
Ben
<?xml version="1.0" ?>
- <DETROITRESPONSE Version="0.5">
- <DETROIT_UVS Stage="L1" StageDescription="Select Criteria">
- <PARAMETER Name="ManCode" Desc="Manufacturer" Type="Select" Value="-1" ROC="no">
<OPTION Text="All Manufacturers" Value="0" />
<OPTION Text="ALFA ROMEO" Value="1" />
<OPTION Text="AUDI" Value="164" />
<OPTION Text="BMW" Value="869" />
<OPTION Text="CHRYSLER" Value="14786" />
<OPTION Text="CITROEN" Value="1333" />
<OPTION Text="DAEWOO" Value="1933" />
<OPTION Text="DAIHATSU" Value="1962" />
<OPTION Text="FIAT" Value="2193" />
<OPTION Text="FORD" Value="2514" />
<OPTION Text="HONDA" Value="4256" />
<OPTION Text="JAGUAR" Value="4721" />
<OPTION Text="JEEP" Value="1283" />
<OPTION Text="KIA" Value="4835" />
<OPTION Text="LAND ROVER" Value="5088" />
<OPTION Text="LEXUS" Value="5171" />
<OPTION Text="MAZDA" Value="5261" />
<OPTION Text="MERCEDES-BENZ" Value="5509" />
<OPTION Text="MG" Value="22417" />
<OPTION Text="MITSUBISHI" Value="6058" />
<OPTION Text="NISSAN" Value="6425" />
<OPTION Text="PEUGEOT" Value="7104" />
<OPTION Text="RENAULT" Value="8219" />
<OPTION Text="ROVER" Value="8959" />
<OPTION Text="SAAB" Value="9572" />
<OPTION Text="SEAT" Value="9909" />
<OPTION Text="SKODA" Value="10172" />
<OPTION Text="SUBARU" Value="10251" />
<OPTION Text="SUZUKI" Value="10383" />
<OPTION Text="TOYOTA" Value="10519" />
<OPTION Text="VAUXHALL" Value="10968" />
<OPTION Text="VOLKSWAGEN" Value="12243" />
<OPTION Text="VOLVO" Value="12764" />
</PARAMETER>
- <PARAMETER Name="BodyStyle" Desc="Body Type" Type="Select" Value="" ROC="no">
<OPTION Text="Any Body Style" Value="-1" />
<OPTION Text="Coupe" Value="C" />
<OPTION Text="Estate" Value="E" />
<OPTION Text="Hatchback" Value="H" />
<OPTION Text="Off Road" Value="O" />
<OPTION Text="Tourer" Value="T" />
<OPTION Text="Saloon" Value="S" />
<OPTION Text="Convertible" Value="V" />
</PARAMETER>
- <PARAMETER Name="GenericColour" Desc="Colour" Type="Select" Value="-1" ROC="no">
<OPTION Text="Any Colour" Value="-1" />
<OPTION Text="Beige" Value="6" />
<OPTION Text="Black" Value="5" />
<OPTION Text="Blue" Value="1" />
<OPTION Text="Brown" Value="3" />
<OPTION Text="Gold" Value="16" />
<OPTION Text="Green" Value="2" />
<OPTION Text="Grey" Value="13" />
<OPTION Text="Orange" Value="10" />
<OPTION Text="Pink" Value="8" />
<OPTION Text="Purple" Value="12" />
<OPTION Text="Red" Value="4" />
<OPTION Text="Silver" Value="15" />
<OPTION Text="White" Value="11" />
<OPTION Text="Yellow" Value="9" />
</PARAMETER>
- <PARAMETER Type="Select" Name="PriceLower" Desc="Lower Price" Value="-1" ROC="no">
<OPTION Text="Any Price" Value="-1" />
<OPTION Text="500" Value="500" />
<OPTION Text="1,000" Value="1000" />
<OPTION Text="1,500" Value="1500" />
<OPTION Text="2,000" Value="2000" />
<OPTION Text="2,500" Value="2500" />
<OPTION Text="3,000" Value="3000" />
<OPTION Text="4,000" Value="4000" />
<OPTION Text="5,000" Value="5000" />
<OPTION Text="6,000" Value="6000" />
<OPTION Text="7,000" Value="7000" />
<OPTION Text="8,000" Value="8000" />
<OPTION Text="9,000" Value="9000" />
<OPTION Text="10,000" Value="10000" />
<OPTION Text="11,000" Value="11000" />
<OPTION Text="12,000" Value="12000" />
<OPTION Text="14,000" Value="14000" />
<OPTION Text="16,000" Value="16000" />
<OPTION Text="18,000" Value="18000" />
<OPTION Text="25,000" Value="25000" />
<OPTION Text="50,000" Value="50000" />
<OPTION Text="75,000" Value="75000" />
</PARAMETER>
- <PARAMETER Type="Select" Name="PriceUpper" Desc="Upper Price" Value="-1" ROC="no">
<OPTION Text="Any Price" Value="-1" />
<OPTION Text="500" Value="500" />
<OPTION Text="1,000" Value="1000" />
<OPTION Text="1,500" Value="1500" />
<OPTION Text="2,000" Value="2000" />
<OPTION Text="2,500" Value="2500" />
<OPTION Text="3,000" Value="3000" />
<OPTION Text="4,000" Value="4000" />
<OPTION Text="5,000" Value="5000" />
<OPTION Text="6,000" Value="6000" />
<OPTION Text="7,000" Value="7000" />
<OPTION Text="8,000" Value="8000" />
<OPTION Text="9,000" Value="9000" />
<OPTION Text="10,000" Value="10000" />
<OPTION Text="11,000" Value="11000" />
<OPTION Text="12,000" Value="12000" />
<OPTION Text="14,000" Value="14000" />
<OPTION Text="16,000" Value="16000" />
<OPTION Text="18,000" Value="18000" />
<OPTION Text="25,000" Value="25000" />
<OPTION Text="50,000" Value="50000" />
<OPTION Text="75,000" Value="75000" />
<OPTION Text="100,000" Value="100000" />
<OPTION Text="100,000+" Value="-2" />
</PARAMETER>
- <PARAMETER Type="Select" Name="Engine" Desc="Engine Size" Value="-1" ROC="no">
<OPTION Text="Any Engine" Value="-1" />
<OPTION Text="Up to 1.2 litres" Value="2" />
<OPTION Text="Between 1.2 litres and 1.6 litres" Value="3" />
<OPTION Text="Between 1.6 litres and 2.0 litres" Value="4" />
<OPTION Text="Between 2.0 litres and 3.0 litres" Value="5" />
<OPTION Text="Over 3.0 litres" Value="6" />
</PARAMETER>
- <PARAMETER Type="Select" Name="Mileage" Desc="Mileage" Value="-1" ROC="no">
<OPTION Text="Any Mileage" Value="-1" />
<OPTION Text="Less than 1,000 miles" Value="2" />
<OPTION Text="Between 1,000 and 2,000 miles" Value="3" />
<OPTION Text="Between 2,000 and 4,000 miles" Value="4" />
<OPTION Text="Between 4,000 and 8,000 miles" Value="5" />
<OPTION Text="Between 8,000 and 16,000 miles" Value="6" />
<OPTION Text="Between 16,000 and 32,000 miles" Value="7" />
<OPTION Text="Between 32,000 and 64,000 miles" Value="8" />
<OPTION Text="Over 64,000 miles" Value="9" />
</PARAMETER>
- <PARAMETER Type="Select" Name="Transmission" Desc="Transmission" Value="" ROC="no">
<OPTION Text="Any Transmission" Value="" />
<OPTION Text="Semi Automatic" Value="S" />
<OPTION Text="Manual" Value="M" />
<OPTION Text="CVT" Value="C" />
<OPTION Text="Automatic" Value="A" />
</PARAMETER>
- <PARAMETER Type="Select" Name="FuelType" Desc="Fuel Type Selection" Value="" ROC="no">
<OPTION Text="Any Fuel Type" Value="" />
<OPTION Text="Bi Fuel" Value="B" />
<OPTION Text="Diesel" Value="D" />
<OPTION Text="Electric" Value="E" />
<OPTION Text="Gas" Value="G" />
<OPTION Text="Hybrid" Value="H" />
<OPTION Text="Petrol" Value="P" />
</PARAMETER>
<PARAMETER Type="Free" Name="Postcode" Desc="Please enter your postcode" />
- <PARAMETER Type="Select" Name="Distance" Desc="Please select a distance" Value="-1" ROC="no">
<OPTION Text="Any Distance" Value="0" />
<OPTION Text="Within 5 Miles" Value="1" />
<OPTION Text="Within 10 Miles" Value="2" />
<OPTION Text="Within 25 Miles" Value="3" />
<OPTION Text="Within 50 Miles" Value="4" />
<OPTION Text="Within 100 Miles" Value="6" />
</PARAMETER>
- <PARAMETER Type="Select" Name="Ordering" Desc="Sort Order" Value="Distance" ROC="no">
<OPTION Text="Distance" Value="4" />
<OPTION Text="Price Low -> High" Value="9" />
<OPTION Text="Price High -> Low" Value="8" />
</PARAMETER>
</DETROIT_UVS>
- <CONTEXT>
<CONTEXTPAIR Name="persist_SubscriberID" Value="91019" />
</CONTEXT>
</DETROITRESPONSE>