androidlogcatgoogle-weather-api

weather forecast application showing errors


I got sample code for weather forecast application from this link:

http://www.anddev.org/viewtopic.php?t=361

and trying to run it on emulator but its showing the errors

I tried a lot to solve It but I couldnt

How to solve this?

In this line I got the errors

xr.parse(new InputSource(url.openStream()));

These are the logcat messages

  05-11 06:39:14.149: E/WeatherForcaster(709): WeatherQueryError
  05-11 06:39:14.149: E/WeatherForcaster(709):   
    org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 190: not well- formed (invalid token)
  05-11 06:39:14.149: E/WeatherForcaster(709): 
    at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:520)                                            
  05-11 06:39:14.149: E/WeatherForcaster(709):  
   at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:479)
      05-11 06:39:14.149: E/WeatherForcaster(709): 
        at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:318)
         05-11 06:39:14.149: E/WeatherForcaster(709):   
          at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:275)    
        05-11 06:39:14.149: E/WeatherForcaster(709): 
         at  org.anddev.android.weatherforecast.Weatherforecast$1.onClick(Weatherforecast.java:74)                                                                                  
       05-11 06:39:14.149: E/WeatherForcaster(709):     
             at android.view.View.performClick(View.java:2485)
       05-11 06:39:14.149: E/WeatherForcaster(709): 
            at android.view.View$PerformClick.run(View.java:9080)
         05-11 06:39:14.149: E/WeatherForcaster(709):   
           at android.os.Handler.handleCallback(Handler.java:587)
            05-11 06:39:14.149: E/WeatherForcaster(709):    
             at android.os.Handler.dispatchMessage(Handler.java:92)
            05-11 06:39:14.149: E/WeatherForcaster(709):    
              at android.os.Looper.loop(Looper.java:123)
               05-11 06:39:14.149: E/WeatherForcaster(709): 
                at android.app.ActivityThread.main(ActivityThread.java:3683)    
               05-11 06:39:14.149: E/WeatherForcaster(709):     
                at java.lang.reflect.Method.invokeNative(Native Method)
     05-11 06:39:14.149: E/WeatherForcaster(709):   
               at java.lang.reflect.Method.invoke(Method.java:507)
         05-11 06:39:14.149: E/WeatherForcaster(709):   
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
      05-11 06:39:14.149: E/WeatherForcaster(709):  
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

Solution

  • You may have problem with encoding of source XML. Try to set encoding of InputSource to UTF8. Here is an example:

        InputSource is = new InputSource(url.openStream());
        is.setEncoding("UTF-8");
        xr.parse(is);