This question seems to come up fairly frequently, so I am putting a pointer in my blog for quick reference.
In another blog entry, “Use ASP.NET Data Binding to Bind Directly to XML (sans DataSet)”, I showed how you can use an XmlNodeList as the source for ASP.NET data binding because it implements the IEnumerable interface. I also blogged about “Getting XML From Somewhere Else”, explaining how you can use the System.Net.HttpWebRequest to issue an HTTP GET to an external URI by providing the System.Net.DefaultCredentials for anonymous authentication. Here is yet another variation on the same concept, only this time I show how to use an intermediary DataSet as the source for the data source. I even put it in VB, hoping to ward off the inevitable “what is the VB syntax for this“ comment.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim url As String = "http://www.autolocate.co.uk/usedcar/search/lifestyle.asp?dealersubscriberid=100540&output=xml"
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
myHttpWebRequest.Credentials = CredentialCache.DefaultCredentials
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Dim resp As System.IO.Stream = myHttpWebResponse.GetResponseStream()
Dim ds As DataSet = New DataSet
ds.ReadXml(resp)
resp.Close()
Me.DropDownList1.DataSource = New DataView(ds.Tables("OPTION"))
Me.DropDownList1.DataTextField = "Text"
Me.DropDownList1.DataValueField = "Value"
Me.DropDownList1.DataBind()
ds.Dispose()
End Sub