/[projects]/android/Side9/src/dk/thoerup/side9/Side9Xml.java
ViewVC logotype

Diff of /android/Side9/src/dk/thoerup/side9/Side9Xml.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 793 by torben, Thu Jun 3 09:39:56 2010 UTC revision 855 by torben, Wed Jun 16 07:44:42 2010 UTC
# Line 11  import javax.xml.parsers.DocumentBuilder Line 11  import javax.xml.parsers.DocumentBuilder
11  import javax.xml.parsers.DocumentBuilderFactory;  import javax.xml.parsers.DocumentBuilderFactory;
12  import javax.xml.parsers.ParserConfigurationException;  import javax.xml.parsers.ParserConfigurationException;
13    
14    
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;
# Line 25  public class Side9Xml { Line 26  public class Side9Xml {
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                  return  builder.parse( new ByteArrayInputStream(str.getBytes()) );                                
33                    return  builder.parse( new ByteArrayInputStream( data)  );              
34          }          }
35                    
36                    
37          public static byte[] getContent(String uri) throws IOException {          public static byte[] getContent(String uri) throws IOException {
38                  byte buffer[] = new byte[256];                  byte buffer[] = new byte[256];
39                                    
40    
41                    
42                  ByteArrayOutputStream baos = new ByteArrayOutputStream(32768); //start buffer size - instead of default 32bytes                  ByteArrayOutputStream baos = new ByteArrayOutputStream(32768); //start buffer size - instead of default 32bytes
43                                    
44                  URL url = new URL(uri);                  URL url = new URL(uri);
# Line 60  public class Side9Xml { Line 64  public class Side9Xml {
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 );                
                 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();

Legend:
Removed from v.793  
changed lines
  Added in v.855

  ViewVC Help
Powered by ViewVC 1.1.20