【发布时间】:2015-04-08 12:29:59
【问题描述】:
我的意思是我有 xml 文件检索我想要它作为 xml 文件的数据库,并且有我想在谷歌地图上显示它的字段,例如“城市、国家、街道、经度、纬度”我想从这些字段中获取值和在谷歌地图上显示它。我想在页面加载事件中显示这个地图。问题我不知道如何从 xml 文件中检索数据并将其传递给地图。
这是后面的代码,
void GetTableFromXMlData(string strResult)
{
CreateTable();
XmlDataDocument xmlDataDoc = new XmlDataDocument();
xmlDataDoc.LoadXml(strResult);
foreach (XmlNode n in xmlDataDoc.DocumentElement.GetElementsByTagName("Property"))
{
DataRow dr = dtSearchResult.NewRow();
dr["HotelID"] = n.Attributes["IDHotel"].Value;
dr["HotelName"] = n.Attributes["Hotelname"].Value;
dr["MinRate"] = n.Attributes["MinRate"].Value;
dr["MaxRate"] = n.Attributes["MaxRate"].Value;
dr["StarCategory"] = n.Attributes["StarCategory"].Value;
dr["ImageIdentifier"] = n.Attributes["ImageIdentifier"].Value;
dr["VPhotoPath"] = strVirtualPath + n.Attributes["ImageIdentifier"].Value + "_Exterior.jpg";
if (n.HasChildNodes)
{
foreach (XmlNode childNode in n)
{
switch (childNode.Name)
{
case "GEOData":///----->>>> here this the data i want to display it in a map.
{
dr["CountryCode"] = childNode.Attributes["CountryCode"].Value;
dr["CityName"] = childNode.Attributes["City"].Value;
dr["CityID"] = childNode.Attributes["IDCity"].Value;
dr["Zip"] = childNode.Attributes["Zip"].Value;
dr["Street"] = childNode.Attributes["Street"].Value;
dr["Longitude"] = childNode.Attributes["Longitude"].Value;
dr["Latitude"] = childNode.Attributes["Latitude"].Value;
break;
}
case "Distances":
{
foreach (XmlNode cChildNode in childNode)
{
if (cChildNode.Attributes["Type"].Value == "1")
dr["DistanceToCity"] = cChildNode.Attributes["Distance"].Value;
else
dr["DistanceToAirPort"] = cChildNode.Attributes["Distance"].Value;
}
break;
}
case "Descriptions":
{
dr["Descriptions"] = childNode.FirstChild.Attributes["Text"].Value;
((Label)FindControl("lblHoDescription1")).Text = childNode.FirstChild.Attributes["Text"].Value;
break;
}
case "Meals":
{
dr["MinimumMeals"] = childNode.Attributes["MinimumMeals"].Value;
break;
}
default: break;
}
}
}
dtSearchResult.Rows.Add(dr);
}
}
【问题讨论】:
标签: javascript asp.net xml google-maps google-maps-api-3