android - documentbuilderfactory 不适用于 android 3.0

标签 android xml android-3.0-honeycomb

这是我用于 android 2.3 的代码。它用于正常工作。 但是不知道为什么它在 android 3.0 中似乎不起作用

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        try
        {

            try
            {
            while(this.xml.available()>0)
            Log.e("content", ""+this.xml.read());
            }
            catch (Exception e) {
                // TODO: handle exception
                Log.e("error", "while reading the file");
            }
            this.xml.reset();

            DocumentBuilder builder = factory.newDocumentBuilder();
            Document dom = builder.parse(this.xml);
            Element root = dom.getDocumentElement();
            Log.d(TAG, "have root?"+dom.getLocalName());;
            Log.d(TAG, "have root?"+dom.getInputEncoding());;
            Log.d(TAG, "have root?"+dom.getNodeValue());;
 }
        catch (Exception e)
        {
             Log.e(TAG, e.getMessage(), e);
        }
        //Log.d(TAG, "Exit:  parse");
        return stores;
    }

内部同时以数字显示文件内容。 但是当我得到 dom.* 我得到 null 为什么会这样?

有什么建议吗?

最佳答案

实际上在 Android 3.0 之前的 Android 版本的 DOM 中存在一些错误 这些错误在 3.0 中得到纠正,因此您使用 DOM 完成的旧实现中可能需要进行一些更改

请引用此链接

http://code.google.com/p/android/issues/detail?id=2735#c11

干杯 喜满树

关于android - documentbuilderfactory 不适用于 android 3.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6263642/

相关文章:

java - 点击 Android 对话框外部以将其关闭?

android - window.location.reload() 导致 PhoneGap 1.4/Android Honeycomb 3.2.1 上的应用程序错误

android - 是否有像android这样的移动开发硕士学位?

java - 我可以为特殊配置获取颜色资源的颜色吗?

java - 移除 ns2 作为默认命名空间前缀

Android TabWidget 不同标签的不同xml文件

javascript - Android-Java & JavaScript(Webview) 之间的桥梁

android - 如何以编程方式获取 colorAccent 等内置资源的值(value)?

java - 根据列表项的位置替换 fragment

Android加载器,要走的路?