Sunday, September 18, 2011

[android-developers] Using Google weather api in android (can't parse Xml correctly)

hi, i m trying to use google weather api. it sends an xml . but i cant
Parse the xml data.

~~~~here, u can see the xml . to click the url :

http://www.google.com/ig/api?weather=New%20York,%20USA

~~~ i use below method to get xml data but i can't .

NodeList nodes = doc.getElementsByTagName("weather");

for (int i = 0; i < nodes.getLength(); i++) {
HashMap<String, String> map = new HashMap<String, String>();

Element e = (Element)nodes.item(i);

map.put("city", "City" + XMLfunctions.getValue(e, "city"));
map.put("ForeCast ", "Fore_cast Date:" +
XMLfunctions.getValue(e, "forecast_date"));
mylist.add(map);
}


ListAdapter adapter = new SimpleAdapter(this, mylist ,
R.layout.main,
new String[] { "city", "ForeCast" },
new int[] { R.id.item_title,
R.id.item_subtitle });

~~~~ here i use hash map .. but that doesn't matter ..

~~~ i want t use the below tag data which is above link.

* <current_conditions>

<condition data="Mostly Cloudy"/>
<temp_f data="63"/>
<temp_c data="17"/>
<humidity data="Humidity: 65%"/>
<icon data="/ig/images/weather/mostly_cloudy.gif"/>
<wind_condition data="Wind: NE at 12 mph"/>

</current_conditions>


************* thanks in advance...

shihab.mi7@gmail.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment