首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

xml解析有关问题,需要输入用户名以及密码

2012-04-28 
xml解析问题,需要输入用户名以及密码?要求:访问指定的网址xml,解析并读取里面的(天文台)信息;网址: http:/

xml解析问题,需要输入用户名以及密码?
要求:访问指定的网址xml,解析并读取里面的(天文台)信息;
网址: http://xml2.weather.gov.hk/V2/bulletins/CurrentWeather_iso-8859-1.xml
demo网址: http://demo.xml.weather.gov.hk/V2/bulletins/CurrentWeather_iso-8859-1.xml.1
现在遇到问题,此网址当用IE去打开时,会弹出对话框需要输入用户名和密码,才能进去;

那么我在用Document解析时,报错了“401错误”,我想是如何在代码里实现用户的登录,后在解析?

Java code
try {    String url = "http://xml2.weather.gov.hk/V2/bulletins/CurrentWeather_iso-8859-1.xml";    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();           DocumentBuilder builder = factory.newDocumentBuilder();           Document doc = builder.parse(url);   //报错}catch(Exception e){}



[解决办法]
网址: http://xml2.weather.gov.hk/V2/bulletins/CurrentWeather_iso-8859-1.xml
这个网址打开是需要输入用户名密码的:打开环境:Safari

demo网址: http://demo.xml.weather.gov.hk/V2/bulletins/CurrentWeather_iso-8859-1.xml.1
这个网址打开不需要输入用户名与密码。

热点排行