<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "Retrieve Wikipedia information by URL"]]></title>
		<link>http://forum.geonames.org/gforum/posts/list/4.page</link>
		<description><![CDATA[Latest messages posted in the topic "Retrieve Wikipedia information by URL"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Retrieve Wikipedia information by URL</title>
				<description><![CDATA[ I'm processing some data where I will have the title (and thus, once it's encoded, the URL) of some Wikipedia articles that I want the coordinates for. I can't find an example of doing this using the Java APi, though it seems to work fine on the web (http://api.geonames.org/wikipediaSearch?title=Philadelphia&maxRows=1&username=demo). 

Naively, I want something like this:
<span class="genmed"><b>Code:</b></span><br>
		<div style="overflow: auto; width: 100%;">
		<pre> myPlace.setWikipediaUrl&#40;"http://en.wikipedia.org/wiki/Philadelphia"&#41;; //OR
myPlace.setTitle&#40;"Philadelphia"&#41;; //and then...
Double lat = myPlace.getLatitude&#40;&#41;;
Double lon = myPlace.getLongitude&#40;&#41;;</pre>
		</div>

But that doesn't actually search anything. However, Webservice.wikipediaSearch doesn't look like it allows you specify the title or URL. 

Doing this would make my app much more efficient; if I know the article is talking about [[Philadelphia]] I can get the coordinates for the exact place that is meant, whereas a simple search of Geonames for "philadelphia" has 2000+ results!]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/list/3745.page#11177</guid>
				<link>http://forum.geonames.org/gforum/posts/list/3745.page#11177</link>
				<pubDate><![CDATA[Fri, 3 Feb 2012 06:29:40]]> GMT</pubDate>
				<author><![CDATA[ bradamant]]></author>
			</item>
			<item>
				<title>Re:Retrieve Wikipedia information by URL</title>
				<description><![CDATA[ di you try the method Webservice.wikipediaSearchForTitle(title,language) ?

Marc]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/list/3745.page#11219</guid>
				<link>http://forum.geonames.org/gforum/posts/list/3745.page#11219</link>
				<pubDate><![CDATA[Sat, 11 Feb 2012 15:36:45]]> GMT</pubDate>
				<author><![CDATA[ marc]]></author>
			</item>
			<item>
				<title>Re:Retrieve Wikipedia information by URL</title>
				<description><![CDATA[ Yes, I tried that last week as well.
<span class="genmed"><b>Code:</b></span><br>
		<div style="overflow: auto; width: 100%;">
		<pre>WebService.setUserName&#40;"myUsername"&#41;;
List&lt;WikipediaArticle&gt; wikiResults = WebService.wikipediaSearchForTitle&#40;
                                "Philadelphia","en"&#41;;
for &#40;WikipediaArticle r : wikiResults&#41; {
     System.out.println&#40;r.getLatitude&#40;&#41;&#41;;
}</pre>
		</div>

Errors start with:
<span class="genmed"><b>Code:</b></span><br>
		<div style="overflow: auto; width: 100%;">
		<pre>Exception in thread "main" java.lang.NoClassDefFoundError: org/jdom/input/SAXBuilder
	at org.geonames.WebService.wikipediaSearchForTitle&#40;Unknown Source&#41;
	at parsetextandurls.ParseTextAndURLs.main&#40;ParseTextAndURLs.java:100&#41;
Caused by: java.lang.ClassNotFoundException: org.jdom.input.SAXBuilder
at java.net.URLClassLoader$1.run&#40;URLClassLoader.java:202&#41;
	at java.security.AccessController.doPrivileged&#40;Native Method&#41;
	at java.net.URLClassLoader.findClass&#40;URLClassLoader.java:190&#41;
	at java.lang.ClassLoader.loadClass&#40;ClassLoader.java:306&#41;
	at sun.misc.Launcher$AppClassLoader.loadClass&#40;Launcher.java:301&#41;
	at java.lang.ClassLoader.loadClass&#40;ClassLoader.java:247&#41;
	... 2 more</pre>
		</div>

It seems like a jdom error, which doesn't appear to be required (if I "import org.jdom.input.SAXBuilder;" it gets marked as unused, too). I tried adding jdom-1.1 to the classpath and still get the same result.]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/list/3745.page#11220</guid>
				<link>http://forum.geonames.org/gforum/posts/list/3745.page#11220</link>
				<pubDate><![CDATA[Sun, 12 Feb 2012 06:50:15]]> GMT</pubDate>
				<author><![CDATA[ bradamant]]></author>
			</item>
			<item>
				<title>Re:Retrieve Wikipedia information by URL</title>
				<description><![CDATA[ jdom is used by the library not directly by your code. You don't have to import it in your code, but it needs to be on the classpath.
I suspect there is something wrong with your classpath.

Best

Marc]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/list/3745.page#11222</guid>
				<link>http://forum.geonames.org/gforum/posts/list/3745.page#11222</link>
				<pubDate><![CDATA[Mon, 13 Feb 2012 07:49:58]]> GMT</pubDate>
				<author><![CDATA[ marc]]></author>
			</item>
			<item>
				<title>Re:Retrieve Wikipedia information by URL</title>
				<description><![CDATA[ Thanks, once I knew I was on the right track I was able to solve the classpath problem. 

But now that the function's working, I don't think it does quite what I need. For example, if I search for Louisiana, the first result is Shreveport, Louisiana (latitude 32.4681) whereas I want just Louisiana (latitude 31.0139). (For some other searches like Philadelphia, the first result *is* the desired one.) 

I already have a function that does a non-exact search of toponym names in GeoNames if it encounters one in free text; I was hoping that if I knew with 100% certainty that a specific Wikipedia article was meant (because it's [[linked]]), I could retrieve just that one location using this alternate method. Is there any way to do that?]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/list/3745.page#11228</guid>
				<link>http://forum.geonames.org/gforum/posts/list/3745.page#11228</link>
				<pubDate><![CDATA[Tue, 14 Feb 2012 06:33:05]]> GMT</pubDate>
				<author><![CDATA[ bradamant]]></author>
			</item>
			<item>
				<title>Re:Retrieve Wikipedia information by URL</title>
				<description><![CDATA[ You can iterate over the result list and get the one with the same name/url.

Best Regards

Marc]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/list/3745.page#11265</guid>
				<link>http://forum.geonames.org/gforum/posts/list/3745.page#11265</link>
				<pubDate><![CDATA[Tue, 21 Feb 2012 08:13:08]]> GMT</pubDate>
				<author><![CDATA[ marc]]></author>
			</item>
	</channel>
</rss>