First, save the xml document so you can examine?it?(Your XPath expression makes no sense.)
string?url?=?"http://maps.google.com/maps/geo?output=xml&key=<your_google_api_key>&q=<city_state>"; XmlDoc.Load(url); XmlDoc.Save(MapPath(@"~\xml\test.xml"));
Second, get a tool like this one so you can?try different XPath expressions:
?Third, if you look at the XML, you can see it uses a namespace.? You need to use it like this:
XmlDocument XmlDoc = new XmlDocument();
XmlNamespaceManager XmlNs = new XmlNamespaceManager(XmlDoc.NameTable);
XmlNs.AddNamespace("def","http://earth.google.com/kml/2.0");
string url = "http://maps.google.com/maps/geo?output=xml&key=<your_google_api_key>&q=<city_state>";
XmlDoc.Load(url);
//XmlDoc.Save(MapPath(@"~\xml\test.xml"));
XmlNodeList Nodes = XmlDoc.SelectNodes("//def:coordinates", XmlNs);
foreach (XmlNode Node in Nodes)
{
Response.Write(Node.InnerText + "<br />");
}
?
vesta williams stanford stanford oklahoma state university badgers badgers nbc sports network
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.