0

I have A XML File that made by a PHP Script:

<?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>

and i'm parsing it using this code in 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 "";
  } 

when my xml is English(For example post id 28 in this xml) it works well

but when my xml is persian(For example post id 25 in this xml) it returns only first character of text .

how can i handle that problem?

Hadi Nahavandi
  • 666
  • 7
  • 18

1 Answers1

0

I found The Answer:

I Should Decode The XML Text In My PHP Script Using html_entity_decode function of PHP

html_entity_decode($this->getXML()->asXML(),ENT_COMPAT,"UTF-8");
Hadi Nahavandi
  • 666
  • 7
  • 18