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();
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)
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);
}