Parser XML qui ne fonctionne pas
Bonjour,
j'ai testé un exemple trouvé sur internet pour parser xml, mais ça n'a pas marché.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| /* Create a URL we want to load some xml-data from. */
URL url = new URL("http://example.com/example.xml");
/* Get a SAXParser from the SAXPArserFactory. */
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
/* Get the XMLReader of the SAXParser we created. */
XMLReader xr = sp.getXMLReader();
/* Create a new ContentHandler and apply it to the XML-Reader*/
ExampleHandler myExampleHandler = new ExampleHandler();
xr.setContentHandler(myExampleHandler);
/* Parse the xml-data from our URL. */
xr.parse(new InputSource(url.openStream()));
/* Parsing has finished. */ |
je l'ai exécuté sur 1 simulateur, et c'est tout noir, rien a affiché. Messages de log:
Code:
1 2 3 4 5 6
| 06-21 14:29:06.434: ERROR/WeatherForcaster(610): java.net.SocketException: The operation timed out
06-21 14:29:06.434: ERROR/WeatherForcaster(610): at org.apache.harmony.luni.platform.OSNetworkSystem.connectSocketImpl(Native Method)
06-21 14:29:06.434: ERROR/WeatherForcaster(610): at org.apache.harmony.luni.platform.OSNetworkSystem.connect(OSNetworkSystem.java:125)
06-21 14:29:06.434: ERROR/WeatherForcaster(610): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:227)
06-21 14:29:06.434: ERROR/WeatherForcaster(610): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:521)
06-21 14:29:06.434: ERROR/WeatherForcaster(610): at java.net.Socket.connect(Socket.java:1019) |
Code:
1 2
| 06-21 14:26:06.367: WARN/ActivityManager(60): Launch timeout has expired, giving up wake lock!
06-21 14:26:06.991: WARN/ActivityManager(60): Activity idle timeout for HistoryRecord{43847740 apps.Parser/.ParsingXML} |
ça me parait le problème de connexion mais je sais pas comment corriger. Quelqu'un peut aider ?
merci !