Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 蜂窝文档分析错误_Android_Parsing_Android 3.0 Honeycomb - Fatal编程技术网

Android 蜂窝文档分析错误

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 {

我已经对这个问题进行了广泛的搜索,尝试了许多修复方法,但都没有成功

我试图从我的服务器解析一个xml文件,我可以检索该文件,但当我去解析它时,它会出错。这是我的密码:

    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不是空的吗


这似乎就是错误所说的。

我修复了它。。。它似乎妨碍了我的工作