【问题标题】:Android JDOM2 xml parsing, IOExcetionAndroid JDOM2 xml解析,IOExcetion
【发布时间】:2016-07-29 18:10:26
【问题描述】:

我正在尝试使用 jdom-2.0.6.jar 从 URL 解析 xml,但我得到 IOException:

IOException: Couldn't open "here is xml link"

我在做什么:

import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;

String myurl = "https://myfile.xml";

  SAXBuilder builder = new SAXBuilder();

  try {
        Document document =  builder.build(myurl);
        Element rootNode = document.getRootElement().getChild("myroot");
      } catch (IOException io) {
        Log.d("IOException", io.getMessage());
    } catch (JDOMException jdomex) {
        Log.d("JDOMException", jdomex.getMessage());
    }

相同的代码在 Eclipse 中运行良好,但在 Android Studio 中却不行。那么有什么问题呢?

【问题讨论】:

    标签: java android xml eclipse jdom-2


    【解决方案1】:

    我在日志中没有(android.os.NetworkOnMainThreadException)异常,但是在使用了这个solution之后我终于解析了xml。

    【讨论】:

      【解决方案2】:

      更改为 Log.w("IOException", io.getMessage(), io) 以获取完整的堆栈跟踪,也许我们可以从那里找出问题。

      【讨论】:

      • 打印相同,没有更多信息。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-30
      • 1970-01-01
      • 1970-01-01
      • 2013-11-06
      • 2012-05-21
      相关资源
      最近更新 更多