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