22 |
|
|
23 |
public class Side9Xml { |
public class Side9Xml { |
24 |
|
|
25 |
static final int WIDTH = 300; |
static final int WIDTH = 450; |
26 |
static final String BASEURL = "http://apps.todic.net/side9/"; |
static final String BASEURL = "http://apps.todic.net/side9/"; |
27 |
|
|
28 |
public static Document parseXML(String str) throws SAXException, IOException, ParserConfigurationException |
public static Document parseXML(String str) throws SAXException, IOException, ParserConfigurationException |
39 |
|
|
40 |
URL url = new URL(uri); |
URL url = new URL(uri); |
41 |
URLConnection connection = url.openConnection(); |
URLConnection connection = url.openConnection(); |
42 |
|
connection.setConnectTimeout(2500); |
43 |
InputStream is = connection.getInputStream(); |
InputStream is = connection.getInputStream(); |
44 |
|
|
45 |
try { |
try { |
57 |
return baos.toByteArray(); |
return baos.toByteArray(); |
58 |
} |
} |
59 |
|
|
60 |
public Side9Data loadXml() throws IOException, ParserConfigurationException, SAXException{ |
public static Side9Data loadXml() throws IOException, ParserConfigurationException, SAXException{ |
61 |
String dataURL = BASEURL + "xml.php?width=" + WIDTH; |
String dataURL = BASEURL + "xml.php?width=" + WIDTH; |
62 |
|
|
63 |
byte data[] = getContent( dataURL ); |
byte data[] = getContent( dataURL ); |
64 |
String xmlData = new String(data, "UTF-8"); |
String xmlData = new String(data, "ISO-8859-1"); |
65 |
Document doc = parseXML(xmlData); |
Document doc = parseXML(xmlData); |
66 |
|
|
67 |
Node rootNode = doc.getDocumentElement(); // stations |
Node rootNode = doc.getDocumentElement(); // stations |