1

I am trying to parse xml from URL with jdom-2.0.6.jar, but i get IOException:

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

That what I am doing:

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());
    }

The same code works well in Eclipse, but not in Android Studio. So what is wrong?

viderSelf
  • 41
  • 5

2 Answers2

1

I did not have in log (android.os.NetworkOnMainThreadException) exception, but after using this solution I finally parsed xml.

Community
  • 1
  • 1
viderSelf
  • 41
  • 5
0

Change to Log.w("IOException", io.getMessage(), io) to get the full stack trace, maybe we can identify the problem from there.