你好,欢迎来到电脑编程技巧与维护杂志社! 杂志社简介广告服务读者反馈编程社区  
合订本订阅
 
 
您的位置:杂志经典 / 网络与通信
用Java实现Yahoo天气预报客户端(十二)
 

links =doc.getElementsByTagName("yweather:astronomy");

nnm=links.item(0).getAttributes();

ywf.jlTodaySunrise.setText("日出时间:"

+nnm.getNamedItem("sunrise").getNodeValue().replaceAll("\\s",""));

ywf.jlTodaySunset.setText("日落时间:+

nnm.getNamedItem("sunset").getNodeValue().replaceAll("\\s",""));         

//解析当前天气相关信息

links =doc.getElementsByTagName("yweather:condition");

nnm=links.item(0).getAttributes();  

int code= Integer.parseInt(

nnm.getNamedItem("code").getNodeValue());

ywf.jlTodayTitle.setText("当前天气情况:"

+fromCodeToText(code));

ImageIcon ii=new ImageIcon("img\\"+code+".png");

ywf.jlTodayImg.setIcon(ii);

ywf.jlTodayDegree.setText("当前气温:"+

nnm.getNamedItem("temp").getNodeValue()+"")

//解析天气预报信息

links =doc.getElementsByTagName("yweather:forecast");

//解析今天天气预报信息

nnm=links.item(0).getAttributes();     

code=Integer.parseInt(nnm.getNamedItem("code").getNodeValue());

ii=new ImageIcon("img\\"+code+".png");

ywf.jlTomorrowImg.setIcon(ii);         

sdf=new SimpleDateFormat("dd MMM yyyy",Locale.US);

date=sdf.parse(

nnm.getNamedItem("date").getNodeValue());

cd=Calendar.getInstance();

cd.setTime(date);

dateStr=(cd.get(Calendar.YEAR))+""

+(cd.get(Calendar.MONTH)+1)+""

+(cd.get(Calendar.DATE))+"";

ywf.jlTomorrowTime.setText("今天:"+dateStr+" "

+fromCodeToText(code));

ywf.jlTomorrowHigh.setText("最高温度:"+

nnm.getNamedItem("high").getNodeValue()+"");   

ywf.jlTomorrowLow.setText("最低温度:"+

nnm.getNamedItem("low").getNodeValue()+"");

//解析明天天气预报信息

nnm=links.item(1).getAttributes();     

code=Integer.parseInt(

nnm.getNamedItem("code").getNodeValue());

ii=new ImageIcon("img\\"+code+".png");

ywf.jlDATImg.setIcon(ii);

sdf=new SimpleDateFormat("dd MMM yyyy",Locale.US);

date=sdf.parse(nnm.getNamedItem("date").getNodeValue());

cd=Calendar.getInstance();

  推荐精品文章

·2024年12月目录 
·2024年11月目录 
·2024年10月目录 
·2024年9月目录 
·2024年8月目录 
·2024年7月目录 
·2024年6月目录 
·2024年5月目录 
·2024年4月目录 
·2024年3月目录 
·2024年2月目录 
·2024年1月目录
·2023年12月目录
·2023年11月目录

  联系方式
TEL:010-82561037
Fax: 010-82561614
QQ: 100164630
Mail:gaojian@comprg.com.cn

  友情链接
 
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved
京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089