Reading in Malformed XML (unencoded XML entities) with PHP

前端 未结 2 1248
难免孤独
难免孤独 2020-12-19 22:35

I\'m having some trouble parsing malformed XML in PHP. In particular I\'m querying a third party webservice that returns data in an XML format without encoding the XML enti

2条回答
  •  猫巷女王i
    2020-12-19 23:14

    1. Read the content as a string.
    2. htmlspecialchars(preg_replace('/[\x-\x8\xb-\xc\xe-\x1f]/','',$string))
    3. Load the transformed string in SimpleXMLElement

    It worked for me so far.

提交回复
热议问题