2014-09-01 4 views
0

Je dispose d'un fichier XML qui fait par un script PHP:analyse syntaxique non-anglais xmls dans Android

<?xml version="1.0"?> 
<posts><post><id>25</id><title>&#x645;&#x62A;&#x646; &#x641;&#x627;&#x631;&#x633;&#x6CC; </title><content>s</content><summary>s</summary></post> <post><id>28</id><title>english text</title><content>1</content> <summary>1</summary></post></posts> 

et je l'analyser en utilisant ce code dans 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 ""; 
    } 

quand mon xml est l'anglais (par exemple post 28 dans ce xml) cela fonctionne bien

mais quand mon xml est persan (par exemple post 25 dans ce xml) il retourne seulement le premier caractère du texte.

comment puis-je gérer ce problème?

+0

Vous avez besoin Html Décodage. voir http://stackoverflow.com/questions/2918920/decode-html-entities-in-android –

Répondre

0

J'ai trouvé la réponse:

I Should Décoder Le texte XML Mon script PHP Utilisation de la fonction html_entity_decode de PHP

html_entity_decode($this->getXML()->asXML(),ENT_COMPAT,"UTF-8");