views:

32

answers:

1

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

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 ^^

+4  A: 

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

Marc Gravell
Thank you very very much :)
icepon