12 |
import org.w3c.dom.Document; |
import org.w3c.dom.Document; |
13 |
import org.w3c.dom.Node; |
import org.w3c.dom.Node; |
14 |
import org.w3c.dom.NodeList; |
import org.w3c.dom.NodeList; |
|
import org.w3c.dom.Text; |
|
15 |
import org.xml.sax.SAXException; |
import org.xml.sax.SAXException; |
16 |
|
|
17 |
import android.location.Location; |
import android.location.Location; |
30 |
} |
} |
31 |
|
|
32 |
@Override |
@Override |
33 |
public void lookupStations(Location location) { |
public boolean lookupStations(Location location) { |
34 |
|
boolean success = false; |
|
//String url = "http://pumba.t-hoerup.dk:8080/TrainInfoService/LocateStations?latitude=" + location.getLatitude() + "&longitude=" + location.getLongitude(); |
|
35 |
String url = "http://app.t-hoerup.dk/TrainInfoService/LocateStations?latitude=" + location.getLatitude() + "&longitude=" + location.getLongitude(); |
String url = "http://app.t-hoerup.dk/TrainInfoService/LocateStations?latitude=" + location.getLatitude() + "&longitude=" + location.getLongitude(); |
36 |
Log.i("url", url); |
Log.i("url", url); |
37 |
try { |
try { |
63 |
|
|
64 |
String nodeName = current.getNodeName(); |
String nodeName = current.getNodeName(); |
65 |
|
|
66 |
Log.i("XML", "" + nodeName + "=" + content); |
if (nodeName.equals("id")) |
67 |
|
station.setId( Integer.parseInt(content)); |
68 |
|
|
69 |
if (nodeName.equals("name")) |
if (nodeName.equals("name")) |
70 |
station.setName(content); |
station.setName(content); |
83 |
|
|
84 |
} |
} |
85 |
stations.add(station); |
stations.add(station); |
86 |
} |
} |
87 |
|
success = true; |
88 |
|
|
89 |
|
|
90 |
} catch (Exception e) { |
} catch (Exception e) { |
91 |
Log.e("XmlStationProvider", "lookupStations: ", e); |
Log.e("XmlStationProvider", "lookupStations: ", e); |
92 |
} |
} |
93 |
|
return success; |
94 |
} |
} |
95 |
|
|
96 |
public Document parseXML(String str) throws SAXException, IOException, ParserConfigurationException |
private Document parseXML(String str) throws SAXException, IOException, ParserConfigurationException |
97 |
{ |
{ |
98 |
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); |
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); |
99 |
return builder.parse( new ByteArrayInputStream(str.getBytes()) ); |
return builder.parse( new ByteArrayInputStream(str.getBytes()) ); |