新浪天气预报接口"/>
java 新浪天气预报接口
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
回复 ? 显示需要的帮助。").append("\n\n");; // 遍历子节点下的子节点// Iterator iters = recordEle.elementIterator("status1"); // 获取子节点head下的子节点script// // // 遍历Header节点下的Response节点// while (iters.hasNext()) { Element itemEle = (Element) iters.next();// // String username = itemEle.elementTextTrim("username"); // 拿到head下的子节点script下的字节点username的值// String password = itemEle.elementTextTrim("password");// // System.out.println("username:" + username);// System.out.println("password:" + password);// } }// Iterator iterss = rootElt.elementIterator("body"); ///获取根节点下的子节点body// // 遍历body节点// while (iterss.hasNext()) {// // Element recordEless = (Element) iterss.next();// String result = recordEless.elementTextTrim("result"); // 拿到body节点下的子节点result值// System.out.println("result:" + result); Iterator itersElIterator = recordEless.elementIterator("form"); // 获取子节点body下的子节点form// // 遍历Header节点下的Response节点// while (itersElIterator.hasNext()) {// // Element itemEle = (Element) itersElIterator.next();// // String banlce = itemEle.elementTextTrim("banlce"); // 拿到body下的子节点form下的字节点banlce的值// String subID = itemEle.elementTextTrim("subID");// System.out.println("banlce:" + banlce);// System.out.println("subID:" + subID);// }// } } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); }
return buff.toString(); }
public static void main(String[] args) {Gettqbycs test=new Gettqbycs();
try {
String instr="福州天气";
System.out.println(instr.substring(2, 4));
String city=instr.substring(0, 2);
String ss= test.Gettqbycs(URLEncoder.encode(city, "GBK"));
String buffstr=test.readStringXml(ss);
System.out.println(buffstr); } catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();} }
}
:咏诘鉮ead下的子节点script// // // 遍历Header节点下的Response节点// while (iters.hasNext()) { Element itemEle = (Element) iters.next();// // String username = itemEle.elementTextTrim("username"); // 拿到head下的子节点script下的字节点username的值// String password = itemEle.elementTextTrim("password");// // System.out.println("username:" + username);// System.out.println("password:" + password);// } }// Iterator iterss = rootElt.elementIterator("body"); ///获取根节点下的子节点body// // 遍历body节点// while (iterss.hasNext()) {// // Element recordEless = (Element) iterss.next();// String result = recordEless.elementTextTrim("result"); // 拿到body节点下的子节点result值// System.out.println("result:" + result); Iterator itersElIterator = recordEless.elementIterator("form"); // 获取子节点body下的子节点form// // 遍历Header节点下的Response节点// while (itersElIterator.hasNext()) {// // Element itemEle = (Element) itersElIterator.next();// // String banlce = itemEle.elementTextTrim("banlce"); // 拿到body下的子节点form下的字节点banlce的值// String subID = itemEle.elementTextTrim("subID");// System.out.println("banlce:" + banlce);// System.out.println("subID:" + subID);// }// } } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); }
return buff.toString(); }
public static void main(String[] args) {Gettqbycs test=new Gettqbycs();
try {
String instr="福州天气";
System.out.println(instr.substring(2, 4));
String city=instr.substring(0, 2);
String ss= test.Gettqbycs(URLEncoder.encode(city, "GBK"));
String buffstr=test.readStringXml(ss);
System.out.println(buffstr); } catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();} }
}
更多推荐
java 新浪天气预报接口
发布评论