Question

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?

Was it helpful?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top