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 –