GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Geonames on java client(android)  XML
Forum Index -> General
Author Message
geodroid



Joined: 19/01/2011 17:32:50
Messages: 1
Offline

Hi

I'm protyping an android client that will use the geonames webservices. Unfortunately I have big problems getting it to work. I get a JDOMParseException (see exception print below). Can u please tell me if I am missing something here?

This is the whole code in the application:


public class GeoSearch extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria();

searchCriteria.setQ("zurich");
ToponymSearchResult searchResult=null;
try {
System.out.println("MRPRint XX1");
searchResult = WebService.search(searchCriteria);

System.out.println("MRPRint XX2");
for (Toponym toponym : searchResult.getToponyms()) {
System.out.println("MRPRint"+toponym.getName()+" "+ toponym.getCountryName());
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}

exception print:
01-19 16:48:19.065: WARN/System.err(8869): org.jdom.input.JDOMParseException: Error on line 18: At line 18, column 67: mismatched tag
01-19 16:48:19.065: WARN/System.err(8869): at org.jdom.input.SAXBuilder.build(SAXBuilder.java:46
01-19 16:48:19.065: WARN/System.err(8869): at org.jdom.input.SAXBuilder.build(SAXBuilder.java:770)
marc



Joined: 08/12/2005 07:39:47
Messages: 4501
Offline

I have run your code in my android eclipse environment and it runs fine. It seems your input is somehow cut and you don't get the full xml document.

Can you print the document you receive? Something like:

URL url = new URL("http://api.geonames.org/search?q=zurich&username=demo");
BufferedReader in = new BufferedReader(new InputStreamReader(
url.openStream()));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}


Marc

[WWW]
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team