我想将所有城市名称添加到下拉列表中。在我的代码中,我只加载了名字。如何更改代码以获取所有信息?
我的 XML:
<country>
<city>
<cityname>Cannes</cityname>
<cityid>123</cityid>
</city>
<city>
<cityname>Paris</cityname>
<cityid>123</cityid>
</city>
<city>
<cityname>Nice</cityname>
<cityid>123</cityid>
</city>
<city>
<cityname>Marseilles</cityname>
<cityid>123</cityid>
</city>
</country>
我的代码:
XElement country= XElement.Load(Server.MapPath("myXML.xml"));
foreach (XElement name in country.Element("city").Elements("cityname"))
{
dropdownList.Items.Add(name.Value);
}