0
非英語個XML我有一個PHP腳本製作的XML文件:解析Android中
<?xml version="1.0"?>
<posts><post><id>25</id><title>متن فارسی </title><content>s</content><summary>s</summary></post> <post><id>28</id><title>english text</title><content>1</content> <summary>1</summary></post></posts>
,我在Android中使用此代碼解析它:
public final String getElementValue(Node elem) {
Node child;
if(elem != null){
if (elem.hasChildNodes()){
for(child = elem.getFirstChild(); child != null; child = child.getNextSibling()){
if(child.getNodeType() == Node.TEXT_NODE )
return child.getNodeValue();
}
}
}
return "";
}
當我xml是英語(例如,在這個xml中的帖子ID爲28)它運作良好
但是當我的xml是波斯語(例如,在這個xml中的帖子id25)它只返回文本的第一個字符。
我該如何處理這個問題?
的我的PHP腳本中使用html_entity_decode功能你需要的Html解碼。見http://stackoverflow.com/questions/2918920/decode-html-entities-in-android – 2014-09-01 21:17:28