--- android/TrainInfo/src/dk/thoerup/traininfo/provider/XmlStationProvider.java 2009/09/07 13:23:48 302 +++ android/TrainInfo/src/dk/thoerup/traininfo/provider/XmlStationProvider.java 2009/09/11 12:24:53 319 @@ -12,7 +12,6 @@ import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import org.w3c.dom.Text; import org.xml.sax.SAXException; import android.location.Location; @@ -31,9 +30,8 @@ } @Override - public void lookupStations(Location location) { - - //String url = "http://pumba.t-hoerup.dk:8080/TrainInfoService/LocateStations?latitude=" + location.getLatitude() + "&longitude=" + location.getLongitude(); + public boolean lookupStations(Location location) { + boolean success = false; String url = "http://app.t-hoerup.dk/TrainInfoService/LocateStations?latitude=" + location.getLatitude() + "&longitude=" + location.getLongitude(); Log.i("url", url); try { @@ -65,7 +63,8 @@ String nodeName = current.getNodeName(); - Log.i("XML", "" + nodeName + "=" + content); + if (nodeName.equals("id")) + station.setId( Integer.parseInt(content)); if (nodeName.equals("name")) station.setName(content); @@ -84,15 +83,17 @@ } stations.add(station); - } + } + success = true; } catch (Exception e) { Log.e("XmlStationProvider", "lookupStations: ", e); } + return success; } - public Document parseXML(String str) throws SAXException, IOException, ParserConfigurationException + private Document parseXML(String str) throws SAXException, IOException, ParserConfigurationException { DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); return builder.parse( new ByteArrayInputStream(str.getBytes()) );