Hi there,

I'm trying to build a GWT project that consult weather information
from Google API Weather. To do this, i'm working with a servlet which
obtain the information in XML format and JDOM. The fact is that Google
API Weather must give:

<xml_api_reply version="1">
-
<weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1"
row="0" section="0">
-
<forecast_information>
<city data="Madrid, Madrid"/>
<postal_code data="madrid"/>
<latitude_e6 data=""/>
<longitude_e6 data=""/>
<forecast_date data="2009-11-24"/>
<current_date_time data="2009-11-24 10:00:00 +0000"/>
<unit_system data="SI"/>
</forecast_information>
-
<current_conditions>
<condition data="Despejado"/>
<temp_f data="50"/>
<temp_c data="10"/>
<humidity data="Humedad: 58%"/>
<icon data="/ig/images/weather/sunny.gif"/>
<wind_condition data="Viento: N a 2 km/h"/>
</current_conditions>
-
<forecast_conditions>
<day_of_week data="mar"/>
<low data="3"/>
<high data="14"/>
<icon data="/ig/images/weather/sunny.gif"/>
<condition data="Despejado"/>
</forecast_conditions>
-
<forecast_conditions>
<day_of_week data="mié"/>
<low data="7"/>
<high data="13"/>
<icon data="/ig/images/weather/mostly_sunny.gif"/>
<condition data="Parcialmente soleado"/>
</forecast_conditions>
-
<forecast_conditions>
<day_of_week data="jue"/>
<low data="4"/>
<high data="13"/>
<icon data="/ig/images/weather/chance_of_rain.gif"/>
<condition data="Posibilidad de lluvia"/>
</forecast_conditions>
-
<forecast_conditions>
<day_of_week data="vie"/>
<low data="2"/>
<high data="13"/>
<icon data="/ig/images/weather/mostly_sunny.gif"/>
<condition data="Mayormente soleado"/>
</forecast_conditions>
</weather>
</xml_api_reply>

But when my servlet reads:

<?xml version="1.0" encoding="UTF-8"?>
<xml_api_reply version="1" />

Any idea why not is the node expand? This is a part of teh code:

public WeatherInformation getWeather(String location) {
                try {
                        //Declaración de constructor de parseador
                        SAXBuilder builder = new SAXBuilder();
                        builder.setExpandEntities(true);

                        //URL de conexión de servicio climático de Google
                        String url = new 
String("http://www.google.com/ig/api?weather"; +
location.toLowerCase().trim() + "&hl=es");
                        URL googleWeatherService = new URL (url);

                        //Construcción de árbol jerárquico XML
                        Document doc = builder.build(googleWeatherService);

                        XMLOutputter out = new XMLOutputter();
                        System.out.println(out.outputString(doc));

                        //Raíz del XML
                        Element root = doc.getRootElement();

                        //Extracción de las condiciones meteorológicas actuales
                        Element xmlElement = 
root.getChild("forecast_information");
                        
data.setLoc(xmlElement.getChild("city").getAttributeValue("data"));

                        xmlElement = root.getChild("current_conditions");
[....]

Thank you very much.

FoN

--

You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.


Reply via email to