PHP encoding with DOMDocument

前端 未结 3 1405
独厮守ぢ
独厮守ぢ 2020-12-02 17:32

Алекс М

When I try to get the content of the following code using DOMDocument functions, it returns something like:

<
3条回答
  •  日久生厌
    2020-12-02 17:59

    Try:

    $string = file_get_contents('your-xml-file.xml');
    $string = mb_convert_encoding($string, 'utf-8', mb_detect_encoding($string));
    // if you have not escaped entities use
    $string = mb_convert_encoding($string, 'html-entities', 'utf-8'); 
    $doc = new DOMDocument();
    $doc->loadXML($string);
    

提交回复
热议问题