I was recently parsing an XML file from a third-party API and found if any tags had CDATA in the contents (e.g. HTML content) it was returning empty. Thankfully, the fix is easy: just pass the LIBXML_NOCDATA
flag to simplexml_load_string
.
$xml = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
