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?
I did not have in log (android.os.NetworkOnMainThreadException) exception, but after using this solution I finally parsed xml.