使用Url接收xml
我想从 url 读取 xml:
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();
这有效。但是当我想读取需要身份验证的网址时,此方法会失败。 所以对于
url = new URL("http://admin:[email protected]/test.xml");
它来说是行不通的。
有什么想法吗?
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:[email protected]/test.xml");
it does not work.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能是这样的东西? http://blogs.deepal.org/2008/01 /sending-basic-authentication-using-url.html
Something, like this, may be? http://blogs.deepal.org/2008/01/sending-basic-authentication-using-url.html