2014-01-29 2 views
0

저는 XML과 ASP.NET의 초보자입니다. 내 요구 사항은 제 3 자 서비스 geonames.org에서받은 xml 응답을 사용하여 드롭 다운을 바인딩하는 것입니다. 예를 들어, 해당 XML 응답에서 국가 이름과 드롭 다운을 바인딩하고 싶습니다. 어떻게하면 가능합니까? http xml 응답을 사용하여 바인드 드롭 다운

는 geonames.org

http://api.geonames.org/countryInfo?username=[myusername]

로부터

<geonames> 
<country> 
<countryCode>AD</countryCode> 
<countryName>Andorra</countryName> 
<isoNumeric>020</isoNumeric> 
<isoAlpha3>AND</isoAlpha3> 
<fipsCode>AN</fipsCode> 
<continent>EU</continent> 
<continentName>Europe</continentName> 
<capital>Andorra la Vella</capital> 
<areaInSqKm>468.0</areaInSqKm> 
<population>84000</population> 
<currencyCode>EUR</currencyCode> 
<languages>ca</languages> 
<geonameId>3041565</geonameId> 
<west>1.4071867141112762</west> 
<north>42.65604389629997</north> 
<east>1.7865427778319827</east> 
<south>42.42849259876837</south> 
</country> 
<country> 
<countryCode>AE</countryCode> 
<countryName>United Arab Emirates</countryName> 
<isoNumeric>784</isoNumeric> 
<isoAlpha3>ARE</isoAlpha3> 
<fipsCode>AE</fipsCode> 
<continent>AS</continent> 
<continentName>Asia</continentName> 
<capital>Abu Dhabi</capital> 
<areaInSqKm>82880.0</areaInSqKm> 
<population>4975593</population> 
<currencyCode>AED</currencyCode> 
<languages>ar-AE,fa,en,hi,ur</languages> 
<geonameId>290557</geonameId> 
<west>51.58332824707031</west> 
<north>26.08415985107422</north> 
<east>56.38166046142578</east> 
<south>22.633329391479492</south> 
</country> 
--------------- 
--------------- 
etc..... 

그래서 응답 XML 아래 예는 위의 URL에서이 구조체의 XML을 반환합니다. 어떻게이를 사용하여 내 드롭 다운을 바인딩 할 수 있습니다.

답변

0

ASP.NET은 XML로 표시된 데이터에 액세스하기위한 XmlDataSource 컨트롤을 제공합니다.

당신은 다음과 같이 바인딩 할 수 있습니다 : 그 지역에있는 나의 작은 지식에 대한

ddlStatus.DataSource = iObjDropDownRetrieval.GetXMLDataSource("~/XMLDatasource/FacilityStatus.xml"); 
ddlStatus.DataTextField = "Name"; 
ddlStatus.DataValueField = "Value"; 
ddlStatus.DataBind(); 
+0

죄송합니다. 내 질문은 어떻게 그 thrirdparty URL에서 XML 응답을이 용도로 사용할 수 있습니다. 즉, http://api.geonames.org/countryInfo?username=[myusername] –

관련 문제