2013-10-02 97 views
1

在我的應用程序中,我嘗試從url獲取xml並嘗試做一些事情。我有2種語言英語和俄語。Android中的無法讀取的文本

我的XML看起來像這樣

<root> 
<dictionary> 
<element name="english_text" lang="en"> 
Hello world 
</element> 
<element name="russian_text" lang="ru"> 
Привет мир 
</element> 
</dictionary> 
</root> 

當解析這個XML儘量表現出來,英語很好,但俄羅斯沒有。

它看起來像這樣。 enter image description here

這裏有什麼問題。請幫助我

+2

看起來像一個編碼問題。歡迎來到地獄。檢查你的編輯器是否使用了我認爲正確的「UTF-8」編碼。 – schlingel

回答

4

當您嘗試解析代碼中的文檔時,您應該使用UTF-8編碼,如果您還沒有這樣做。

如果您正在使用的HttpClient爲此,然後它會看起來像這樣

HttpResponse httpResponse = httpClient.execute(httpPost); 
HttpEntity httpEntity = httpResponse.getEntity(); 
String results = EntityUtils.toString(httpEntity, "UTF-8"); 
+0

我必須在XMLParser類中這樣做嗎? – bauer9664

+0

是的,無論你試圖解析文檔 – nsgulliver

+0

如果我更新我的代碼嘗試添加我的xmlparser你能告訴我更具體嗎? – bauer9664