php XML DOM translates special chars to &#xYY;

Posted by ZiTAL on Stack Overflow See other posts from Stack Overflow or by ZiTAL
Published on 2011-01-07T11:47:18Z Indexed on 2011/01/07 11:53 UTC
Read the original article Hit count: 276

Filed under:
|
|
|
|

I send this with AJAX POST:

<li><ul class   "zone zCentral ui-sortable"><li><ul class="region rCol3 ui-sortable"><li class="" style=""><div><span class="tc tc_video">574081</span> <span>video: 'Mundo.Hoy': ¿Dónde habré olvidado... mi memoria?</span></div></li></ul></li></ul></li>

I do this to create XML:

        header('Content-type: text/html; charset=utf-8');       
    if(isset($_POST) && isset($_POST['data']))
    {           
        $data = '<ul id="zone_container" class="ui-sortable">';
        $data .= $_POST['data'];
        $data .= '</ul>';                           

        $dom = new DOMDocument('1.0', 'utf-8');
        $dom->loadXML($data);

        echo $dom->saveXML();                       
        exit();
    }

and i get this:

<?xml version="1.0"?>
<ul id="zone_container" class="ui-sortable">
    <li><ul class="zone zCentral ui-sortable"><li><ul class="region rCol3         ui-sortable"><li class="" style=""><div><span class="tc tc_video">574081</span>     <span>video: 'Mundo.Hoy': &#xBF;D&#xF3;nde habr&#xE9; olvidado... mi memoria?</span></div>    </li></ul></li></ul></li></ul>

¿Dónde habré olvidado... mi memoria?

translates to:

&#xBF;D&#xF3;nde habr&#xE9 ; olvidado... mi memoria?

Y need original chars in the XML, these are utf-8 valid i don't know the reason for this encode :(

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml