I want to read xml from url:
URL url = new URL("http://192.168.2.20/test.xml");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new InputSource(url.openStream()));
doc.getDocumentElement().normalize();
This works. But when I want to read from a url that needs authentication this method fails.
So for
url = new URL("http://admin:pass@192.168.2.20/test.xml");
it does not work.
Any ideas?
Something, like this, may be? http://blogs.deepal.org/2008/01/sending-basic-authentication-using-url.html