PHP not have a function for XML-safe entity decode? Not have some xml_entity_decode?

后端 未结 6 1888
旧时难觅i
旧时难觅i 2020-12-17 02:20

THE PROBLEM: I need a XML file \"full encoded\" by UTF8; that is, with no entity representing symbols, all symbols enconded by UTF8, except the only 3 ones that are

6条回答
  •  攒了一身酷
    2020-12-17 02:58

    Use the DTD when loading the JATS XML document, as it will define any mapping from named entities to Unicode characters, then set the encoding to UTF-8 when saving:

    $doc = new DOMDocument;
    $doc->load($inputFile, LIBXML_DTDLOAD | LIBXML_NOENT);
    $doc->encoding = 'UTF-8';
    $doc->save($outputFile);
    

提交回复
热议问题