我是VB.net的新手,我無法確定如何從HttpWebRequest將XML數據加載到DropDownList中。我想要加載到DropDownList中的數據是Merchant + Price。樓下是我的代碼:從HttpWebRequest XML填充DropDownList XML VB.net
Dim s As HttpWebRequest
s = HttpWebRequest.Create("myURL")
s.Method = "GET"
Dim postresponse As HttpWebResponse
postresponse = DirectCast(s.GetResponse, HttpWebResponse)
Dim postreqreader As New Stream(postresponse.GetResponseStream())
Dim returnData As String = postreqreader.ReadToEnd
postresponse.Close()
我從returnData找回XML響應是:
<xml version="1.0" encoding="UTF-8" ?>
<Response>
<ID>123</ID>
<Items>
<Item>
<Isbn>123456789</Isbn>
<Offers>
<Offer>
<Isbn>123456789</Isbn>
<Merchant>Vendor1</Merchant>
<Price>3.00</Price>
<Shipping>8.00<Shipping>
</Offer>
<Offer>
<Isbn>123456789</Isbn>
<Merchant>Verndor2</Merchant>
<Price>3.00</Price>
<Shipping>8.00<Shipping>
</Offer>
</Offers>
</Item>
</Items>
</Response>
感謝。這項工作。我如何將下拉菜單中的兩個或多個字段組合在一起? – Kluong
當然。只更新了代碼以顯示兩個字段 – ElenaDBA