/[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 854 by torben, Wed Jun 16 07:40:59 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  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;
# Line 29  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                                    
33                  return  builder.parse( new ByteArrayInputStream(str.getBytes()) );                                return  builder.parse( new ByteArrayInputStream( data)  );              
34          }          }
35                    
36                    
# Line 67  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 );                
                 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();

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

  ViewVC Help
Powered by ViewVC 1.1.20