【发布时间】:2012-05-17 03:01:55
【问题描述】:
我正在使用 SAX 从 google 天气 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 作业?
-
Sax 似乎是解析这个的最简单方法。不过,我完全愿意学习一种新的方式。
-
Google 天气 API 于 2012 年关闭 -> stackoverflow.com/questions/12145820/google-weather-api-gone/…
标签: java api weather weather-api google-weather-api