Android 蜂窝文档分析错误
我已经对这个问题进行了广泛的搜索,尝试了许多修复方法,但都没有成功 我试图从我的服务器解析一个xml文件,我可以检索该文件,但当我去解析它时,它会出错。这是我的密码:Android 蜂窝文档分析错误,android,parsing,android-3.0-honeycomb,Android,Parsing,Android 3.0 Honeycomb,我已经对这个问题进行了广泛的搜索,尝试了许多修复方法,但都没有成功 我试图从我的服务器解析一个xml文件,我可以检索该文件,但当我去解析它时,它会出错。这是我的密码: public final static Document parse(String xml){ Document doc = null; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try {
public final static Document parse(String xml){
Document doc = null;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
// ERRORS HERE
is.setCharacterStream(new StringReader(xml));
//
doc = db.parse(is);
} catch (ParserConfigurationException e) {
System.out.println("XML parse error: " + e.getMessage());
return null;
} catch (SAXException e) {
System.out.println("Wrong XML file structure: " + e.getMessage());
return null;
} catch (IOException e) {
System.out.println("I/O exeption: " + e.getMessage());
return null;
}
return doc;
}
下面是我得到的错误:
12-02 20:26:22.340: E/AndroidRuntime(11600): java.lang.NullPointerException
12-02 20:26:22.340: E/AndroidRuntime(11600): at java.io.StringReader.<init>(StringReader.java:48)
12-02 20:26:22.340: E/AndroidRuntime(11600): at com.arayray.bootanimationutility.tablet.functions.DownloadFunctions.parse(DownloadFunctions.java:41)
您确定xml不是空的吗
这似乎就是错误所说的。我修复了它。。。它似乎妨碍了我的工作