11 |
import javax.xml.parsers.DocumentBuilderFactory; |
import javax.xml.parsers.DocumentBuilderFactory; |
12 |
import javax.xml.parsers.ParserConfigurationException; |
import javax.xml.parsers.ParserConfigurationException; |
13 |
|
|
14 |
import org.apache.http.HttpResponse; |
|
|
import org.apache.http.client.HttpClient; |
|
|
import org.apache.http.client.methods.HttpGet; |
|
|
import org.apache.http.impl.client.DefaultHttpClient; |
|
15 |
import org.w3c.dom.Document; |
import org.w3c.dom.Document; |
16 |
import org.w3c.dom.Node; |
import org.w3c.dom.Node; |
17 |
import org.w3c.dom.NodeList; |
import org.w3c.dom.NodeList; |
26 |
static final int WIDTH = 450; |
static final int WIDTH = 450; |
27 |
static final String BASEURL = "http://apps.todic.net/side9/"; |
static final String BASEURL = "http://apps.todic.net/side9/"; |
28 |
|
|
29 |
public static Document parseXML(String str) throws SAXException, IOException, ParserConfigurationException |
public static Document parseXML(byte data[]) throws SAXException, IOException, ParserConfigurationException |
30 |
{ |
{ |
31 |
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); |
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); |
32 |
|
|
33 |
return builder.parse( new ByteArrayInputStream(str.getBytes()) ); |
return builder.parse( new ByteArrayInputStream( data) ); |
34 |
} |
} |
35 |
|
|
36 |
|
|
64 |
public static Side9Data loadXml() throws IOException, ParserConfigurationException, SAXException{ |
public static Side9Data loadXml() throws IOException, ParserConfigurationException, SAXException{ |
65 |
String dataURL = BASEURL + "xml.php?width=" + WIDTH; |
String dataURL = BASEURL + "xml.php?width=" + WIDTH; |
66 |
|
|
67 |
byte data[] = getContent( dataURL ); |
byte data[] = getContent( dataURL ); |
68 |
String xmlData = new String(data, "ISO-8859-1"); |
Document doc = parseXML( data ); |
|
xmlData = xmlData.replace("encoding=\"ISO-8859-1\"", ""); |
|
|
|
|
|
Document doc = parseXML(xmlData); |
|
69 |
|
|
70 |
Node rootNode = doc.getDocumentElement(); // stations |
Node rootNode = doc.getDocumentElement(); // stations |
71 |
NodeList nodes = rootNode.getChildNodes(); |
NodeList nodes = rootNode.getChildNodes(); |