/[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 853 by torben, Thu Jun 3 09:39:56 2010 UTC revision 854 by torben, Wed Jun 16 07:40:59 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;
15    import org.apache.http.client.HttpClient;
16    import org.apache.http.client.methods.HttpGet;
17    import org.apache.http.impl.client.DefaultHttpClient;
18  import org.w3c.dom.Document;  import org.w3c.dom.Document;
19  import org.w3c.dom.Node;  import org.w3c.dom.Node;
20  import org.w3c.dom.NodeList;  import org.w3c.dom.NodeList;
# Line 28  public class Side9Xml { Line 32  public class Side9Xml {
32          public static Document parseXML(String str) throws SAXException, IOException, ParserConfigurationException          public static Document parseXML(String str) throws SAXException, IOException, ParserConfigurationException
33          {          {
34                  DocumentBuilder builder =  DocumentBuilderFactory.newInstance().newDocumentBuilder();                  DocumentBuilder builder =  DocumentBuilderFactory.newInstance().newDocumentBuilder();
35                    
36                  return  builder.parse( new ByteArrayInputStream(str.getBytes()) );                                return  builder.parse( new ByteArrayInputStream(str.getBytes()) );              
37          }          }
38                    
# Line 35  public class Side9Xml { Line 40  public class Side9Xml {
40          public static byte[] getContent(String uri) throws IOException {          public static byte[] getContent(String uri) throws IOException {
41                  byte buffer[] = new byte[256];                  byte buffer[] = new byte[256];
42                                    
43    
44                    
45                  ByteArrayOutputStream baos = new ByteArrayOutputStream(32768); //start buffer size - instead of default 32bytes                  ByteArrayOutputStream baos = new ByteArrayOutputStream(32768); //start buffer size - instead of default 32bytes
46                                    
47                  URL url = new URL(uri);                  URL url = new URL(uri);
# Line 62  public class Side9Xml { Line 69  public class Side9Xml {
69                                    
70                  byte data[] = getContent( dataURL );                  byte data[] = getContent( dataURL );
71                  String xmlData = new String(data, "ISO-8859-1");                  String xmlData = new String(data, "ISO-8859-1");
72                    xmlData = xmlData.replace("encoding=\"ISO-8859-1\"", "");
73                    
74                  Document doc = parseXML(xmlData);                                Document doc = parseXML(xmlData);              
75                                    
76                  Node rootNode = doc.getDocumentElement(); // stations                  Node rootNode = doc.getDocumentElement(); // stations

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

  ViewVC Help
Powered by ViewVC 1.1.20