Geotagging in xml can't be use in c#
I'm new in twitter api and now i try to get the geotagging from xml data of twitter
my code for get geo code is
XmlNode eNode = xn.SelectSingleNode("coordinates/georss:point");
error is
开发者_JS百科XPathException was unhandle by user code
-Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.
but for other data suchas name, text or id is work fine to get it
thanks for your help ^^
It speaks the truth. Simply declare an XmlNamespaceManager
, and tell it what uri "georss" refers to:
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("georss", "http://www.georss.org/georss");
and pass ns
into the SelectSingleNode
call:
XmlNode eNode = xn.SelectSingleNode("coordinates/georss:point", nsmgr);
You should be able to find the uri from the xmlns
alias declaration at the top of the xml (edit: @dtb found it already).
精彩评论