Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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 XML解析随机行为_Android_Xml - Fatal编程技术网

Android XML解析随机行为

Android XML解析随机行为,android,xml,Android,Xml,当我试图解析一个XML文件时,会出现一种奇怪的随机行为。有时它是有效的,但在大多数情况下,我得到: ExpatParser$ParseException: At line 1, column 0: no element found 我的XML看起来不错,但是: <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> <myTaxiControl version="1.0"> <Cache0> <

当我试图解析一个XML文件时,会出现一种奇怪的随机行为。有时它是有效的,但在大多数情况下,我得到:

ExpatParser$ParseException: At line 1, column 0: no element found
我的XML看起来不错,但是:

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<myTaxiControl version="1.0">
<Cache0>
<digits>1</digits>
<area_bigcar_surch/>


我意识到我的文件中有&个,这是不允许的(应该是&)。将通过替换&

重试。有时您的httpcall似乎没有收到XML响应。否,我的文件存储在SD卡上。您如何阅读?发布一些与读取文件相关的代码。似乎发生了一些重叠。没有人知道问题可能是什么?@michaelsmith,请确保您没有尝试两次解析同一输入流。
FileInputStream fileos;
    try {
        File f = new File(Environment.getExternalStorageDirectory()+"/TarifsCache1.txt");
        fileos = new FileInputStream(f);
    } catch (FileNotFoundException e) {
        return null;
    }
SAXParserFactory factory = SAXParserFactory.newInstance();
    SAXParser parser=null;
    try {
        parser = factory.newSAXParser();
    XMLReader reader=null;
    reader = parser.getXMLReader();
    MySaxHandler handler = new MySaxHandler();
    reader.setContentHandler(handler);
    InputSource input = new InputSource(fileos);
    reader.parse(input);
    handler.close();// last one would be missed
    tarifsfound = handler.tarifsfound;// .tarifsfound;
    } catch (SAXException e) {
        Log.d("TTT","WHY???");
    }