DocumentBuilder.parse时的StringIndexOutOfBoundsException

时间:2015-11-27 21:22:48

标签: android xpath xml-parsing

这是我的代码

  public void loadxml(String path)
    {
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            document= builder.parse(new FileInputStream(path));
            xPath =  XPathFactory.newInstance().newXPath();

        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }

    }

我正在尝试阅读一个大的xml, (当具有相同结构的短xml时,这可以正常工作)

        document= builder.parse(new FileInputStream(path));

(我尝试使用File,但我得到了同样的错误)

我得到了

java.lang.StringIndexOutOfBoundsException: length=35; index=35

我在Android编程

更多信息StackTrace

0 = {StackTraceElement@830033891712} "org.kxml2.io.KXmlParser.setInput(KXmlParser.java:1680)"
1 = {StackTraceElement@830033892008} "org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:111)"
2 = {StackTraceElement@830033892360} "javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:107)"
3 = {StackTraceElement@830033892672} "plenumsoft.iniciativayucatan.Base.Utils.XmlUtil.loadxml(XmlUtil.java:34)"
4 = {StackTraceElement@830033893008} "plenumsoft.iniciativayucatan.DataManager.ListDataManager.<init>(ListDataManager.java:28)"
5 = {StackTraceElement@830033893368} "plenumsoft.iniciativayucatan.ui.Fragment.sitios_list.cargarlistado(sitios_list.java:126)"
6 = {StackTraceElement@830033893728} "plenumsoft.iniciativayucatan.ui.Fragment.sitios_list.onViewCreated(sitios_list.java:110)"
7 = {StackTraceElement@830033894088} "android.app.FragmentManagerImpl.moveToState(FragmentManager.java:843)"
8 = {StackTraceElement@830033894416} "android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)"
9 = {StackTraceElement@830033894744} "android.app.BackStackRecord.run(BackStackRecord.java:635)"
10 = {StackTraceElement@830033895048} "android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1399)"
11 = {StackTraceElement@830033895384} "android.app.Activity.performStart(Activity.java:5056)"
12 = {StackTraceElement@830033895672} "android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2065)"
13 = {StackTraceElement@830033896000} "android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)"
14 = {StackTraceElement@830033896328} "android.app.ActivityThread.access$700(ActivityThread.java:134)"
15 = {StackTraceElement@830033896632} "android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)"
16 = {StackTraceElement@830033896952} "android.os.Handler.dispatchMessage(Handler.java:99)"
17 = {StackTraceElement@830033897240} "android.os.Looper.loop(Looper.java:137)"
18 = {StackTraceElement@830033897504} "android.app.ActivityThread.main(ActivityThread.java:4867)"
19 = {StackTraceElement@830033897800} "java.lang.reflect.Method.invokeNative(Native Method)"
20 = {StackTraceElement@830033898096} "java.lang.reflect.Method.invoke(Method.java:511)"
21 = {StackTraceElement@830033898376} "com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)"
22 = {StackTraceElement@830033898720} "com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)"
23 = {StackTraceElement@830033899024} "dalvik.system.NativeStart.main(Native Method)"

0 个答案:

没有答案