开发者

Geotagging in xml can't be use in c#

开发者 https://www.devze.com 2023-01-03 21:07 出处:网络
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

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消