/[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 632 by torben, Tue Mar 23 13:34:52 2010 UTC revision 793 by torben, Thu Jun 3 09:39:56 2010 UTC
# Line 16  import org.w3c.dom.Node; Line 16  import org.w3c.dom.Node;
16  import org.w3c.dom.NodeList;  import org.w3c.dom.NodeList;
17  import org.xml.sax.SAXException;  import org.xml.sax.SAXException;
18    
19    import android.util.Log;
20    
21    
22    
23  public class Side9Xml {  public class Side9Xml {
24                    
25          static final int WIDTH = 100;          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
# Line 37  public class Side9Xml { Line 39  public class Side9Xml {
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 {
# Line 54  public class Side9Xml { Line 57  public class Side9Xml {
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
# Line 85  public class Side9Xml { Line 88  public class Side9Xml {
88                          if (name.equals("caption"))                          if (name.equals("caption"))
89                                  side9Data.caption = content;                                  side9Data.caption = content;
90                  }                  }
91                    
92                    Log.i("Side9Xml", "url:  " + side9Data.url);
93                    Log.i("Side9Xml", "size: " + side9Data.width + "/" + side9Data.height);
94                    Log.i("Side9Xml", "capt: " + side9Data.caption);
95                    
96                                                                    
97                                    
98                                    

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

  ViewVC Help
Powered by ViewVC 1.1.20