0
我正在使用SAX从Google天气API中获取信息,并且遇到了“条件”问题。Google Weather API条件
具体来说,我正在使用此代码:
public void startElement (String uri, String name, String qName, Attributes atts) {
if (qName.compareTo("condition") == 0) {
String cCond = atts.getValue(0);
System.out.println("Current Conditions: " + cCond);
currentConditions.add(cCond);
}
要东西拉这样的XML:
http://www.google.com/ig/api?weather=Boston+MA
同时我试图让条件仅当天,而不是将来的任何日子。
是否有一些检查我可以放入xml中以仅根据XML文件中的内容为当前提取数据?
谢谢!
¿您是否需要使用SAX?这是完全可能的,但这看起来像一个XPath工作? –
萨克斯似乎是解析这个最简单的方法。尽管如此,我仍然在学习新的方式。 –
** Google天气API在2012年被关闭** - > http://stackoverflow.com/questions/12145820/google-weather-api-gone/35943521 –