解析xml文件时出错

时间:2012-04-14 14:07:02

标签: android xml parsing

您好我创建了一个save11111.xml文件并放在服务器上。 Here is code of .xml file
我需要从该文件中获取数据。但是当我试图运行文件时,它显示错误 记录猫。这是logcat

04-14 19:18:58.137: ERROR/AndroidRuntime(22682): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.examguide/com.example.examguide.ReadBooksActivity}: java.lang.IllegalStateException: Target host must not be null, or set in parameters.
04-14 19:18:58.137: ERROR/AndroidRuntime(22682): Caused by: java.lang.IllegalStateException: Target host must not be null, or set in parameters.
04-14 19:18:58.137: ERROR/AndroidRuntime(22682):     at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:572)
04-14 19:18:58.137: ERROR/AndroidRuntime(22682):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
04-14 19:18:58.137: ERROR/AndroidRuntime(22682):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
04-14 19:18:58.137: ERROR/AndroidRuntime(22682):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
04-14 19:18:58.137: ERROR/AndroidRuntime(22682):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:292)
04-14 19:18:58.137: ERROR/AndroidRuntime(22682):     at com.example.examguide.XMLParser.getXmlFromUrl(XMLParser.java:45)
04-14 19:18:58.137: ERROR/AndroidRuntime(22682):     at com.example.examguide.ReadBooksActivity.onCreate(ReadBooksActivity.java:43)  

我不明白我的代码中有什么问题。Here and Here

请给我一些提示或参考 任何帮助都是赞赏的。

1 个答案:

答案 0 :(得分:1)

您忘了在网址中指定协议:

        static final String URL = "http://www.cerebrumtechno.com/Save.xml";