libxml_disable_entity_loader(true); $xmlstring = simplexml_load_string($html, 'SimpleXMLElement', LIBXML_NOCDATA); $val = json_decode(json_encode($xmlstring),true);