PHP5’s SimpleXML Now Passes CDATA Content

I didn’t hear big announcement of it, but [deep in the docs][1] (? PHP 5.1.0) you’ll find a note about [additional Libxml parameters][2]. In there you’ll learn about “LIBXML_NOCDATA,” and it works like this:

simplexml_load_string($xmlraw, ‘SimpleXMLElement’, LIBXML_NOCDATA);

Without that option (and with all previous versions of PHP/SimpleXML), SimpleXML just ignores any < ![CDATA[...]]> ‘escaped’ content, such as you’ll find in most every blog feed.

 [2]: "additional Libxml parameters"

Using XML In PHP5

Everybody likes documentation. The Zend folks posted this overview and SimpleXML introduction The O’Reilly folks at ONLamp offered this guide to using SimpleXML. Of course, there’s always the SimpleXML docs at

Two problems: I haven’t encountered CDATA in my XML yet, but I do hope to develop a better solution than offered here when I do. The other is that SimpleXML chokes on illegal characters, a unfortunately common occurrence in documents coming from III’s XML Server.