2012-05-11 68 views
-1

我從這個鏈接天氣預報應用程序示例代碼:天氣預報應用程序顯示錯誤

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

,並試圖在模擬器中運行,但它顯示我嘗試了很多的錯誤

解決它但我couldnt

如何解決這個問題?

在此行中我得到了錯誤

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

這些都是logcat的消息

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) 

回答

1

你可能有問題,源XML的編碼。 嘗試將InputSource的編碼設置爲UTF8。 下面是一個例子:

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

感謝您的答覆,我想這個代碼,但沒有得到數據。 – Randroid

+0

嘗試檢查xml數據。在第1行,第190列是一個問題。 – Chemik