求解:怎么从URL读取xml文件 现在有个URL,访问其会返回一个从浏览器打开xml文件,现在怎么将该xml读取下来,或者说将该xml内容保存在本地。可以的话给shell脚本命令也行,谢谢!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public org.xml.sax.InputSource(java.lang.String uri);在命令行下可以使用 cURL。 curl "http://www.google.com/ig/api?weather=beijing&hl=zh-cn" | iconv -f gbk -t utf-8 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 1326 0 1326 0 0 1832 0 --:--:-- --:--:-- --:--:-- 3526<?xml version="1.0"?><xml_api_reply version="1"><weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" ><forecast_information><city data="Beijing, Beijing"/><postal_code data="beijing"/><latitude_e6 data=""/><longitude_e6 data=""/><forecast_date data="2011-10-05"/><current_date_time data="2011-10-06 03:30:00 +0000"/><unit_system data="SI"/></forecast_information><current_conditions><condition data="晴"/><temp_f data="57"/><temp_c data="14"/><humidity data="湿度: 77%"/><icon data="/ig/images/weather/sunny.gif"/><wind_condition data="风向: 东北、风速:2 米/秒"/></current_conditions><forecast_conditions><day_of_week data="周三"/><low data="8"/><high data="26"/><icon data="/ig/images/weather/sunny.gif"/><condition data="晴"/></forecast_conditions><forecast_conditions><day_of_week data="周四"/><low data="7"/><high data="23"/><icon data="/ig/images/weather/sunny.gif"/><condition data="晴"/></forecast_conditions><forecast_conditions><day_of_week data="周五"/><low data="10"/><high data="23"/><icon data="/ig/images/weather/sunny.gif"/><condition data="晴"/></forecast_conditions><forecast_conditions><day_of_week data="周六"/><low data="15"/><high data="26"/><icon data="/ig/images/weather/mostly_sunny.gif"/><condition data="以晴为主"/></forecast_conditions></weather></xml_api_reply> 这个必须是linux下吗,我在win7命令行怎么不行 你说shell,我还以为你是linux。在http://curl.haxx.se/download.html这里下载curl,windows版在页面最下方,拖到底后,选择合适的版本下载。 windows shell 可以使用powershellhttp://stackoverflow.com/questions/1819341/how-to-read-xml-file-from-web-using-powershell 麻烦了,请问如果直接想读取通过访问URL返回的xml,采用哪个比较好,大概是什么样的步骤!!谢谢 java.net.URL 不是有 openStream方法, 然后呢URL url=new URL(URL_ALL); URLConnection urlConnection = url.openConnection(); DataInputStream urlDis = new DataInputStream(urlConnection.getInputStream()); Document doc = builder.build(urlDis); Element root = doc.getRootElement(); List child = root.getChildren();这样一个节点一个节点读吗 结贴了:2种方法1:URLConnection urlConnection = url.openConnection();InputStream urlIn = urlConnection.getInputStream();doc = reader.read(urlIn);2:用httpClient皆可 Apache 集群环境 ,DWR的js不能加载。。。 在浏览器中显示word,excel.ppt,pdf等各种文件 servlet 中获取输出的 html ssh 提示找不到 org/dom4j/documentException 求编辑器 高手请帮忙啊!关于Tree取值问题 想控制网站后台管理员权限,有什么办法 求一个字符串抽取的问题 关于logic标签(在线等待) 刚开始学java 问个弱智的问题 在线等候各位的帮忙,急急急!!!!!!!!!! 急急急急!!年龄段查询,select里的value值怎么传到dao方法里
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1326 0 1326 0 0 1832 0 --:--:-- --:--:-- --:--:-- 3526
<?xml version="1.0"?><xml_api_reply version="1"><weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" ><forecast_information><city data="Beijing, Beijing"/><postal_code data="beijing"/><latitude_e6 data=""/><longitude_e6 data=""/><forecast_date data="2011-10-05"/><current_date_time data="2011-10-06 03:30:00 +0000"/><unit_system data="SI"/></forecast_information><current_conditions><condition data="晴"/><temp_f data="57"/><temp_c data="14"/><humidity data="湿度: 77%"/><icon data="/ig/images/weather/sunny.gif"/><wind_condition data="风向: 东北、风速:2 米/秒"/></current_conditions><forecast_conditions><day_of_week data="周三"/><low data="8"/><high data="26"/><icon data="/ig/images/weather/sunny.gif"/><condition data="晴"/></forecast_conditions><forecast_conditions><day_of_week data="周四"/><low data="7"/><high data="23"/><icon data="/ig/images/weather/sunny.gif"/><condition data="晴"/></forecast_conditions><forecast_conditions><day_of_week data="周五"/><low data="10"/><high data="23"/><icon data="/ig/images/weather/sunny.gif"/><condition data="晴"/></forecast_conditions><forecast_conditions><day_of_week data="周六"/><low data="15"/><high data="26"/><icon data="/ig/images/weather/mostly_sunny.gif"/><condition data="以晴为主"/></forecast_conditions></weather></xml_api_reply>
这个必须是linux下吗,我在win7命令行怎么不行
http://stackoverflow.com/questions/1819341/how-to-read-xml-file-from-web-using-powershell
谢谢
URLConnection urlConnection = url.openConnection();
DataInputStream urlDis = new DataInputStream(urlConnection.getInputStream());
Document doc = builder.build(urlDis);
Element root = doc.getRootElement();
List child = root.getChildren();这样一个节点一个节点读吗
1:
URLConnection urlConnection = url.openConnection();
InputStream urlIn = urlConnection.getInputStream();
doc = reader.read(urlIn);
2:用httpClient皆可