Tech Thought

Tech tips, hints, and general musings. PHP, Perl, Mysql, Javascript, AJAX, JSON, Linux, Mac OSX

Entries Tagged ‘xml’

How-To: Fix SimpleXML CDATA problem in php

If you’ve used the SimpleXML functions in PHP, you may have noticed some strange things happening with CDATA values in your XML file/string. All I needed to do was extract the value of my CDATA fields, however these were always coming back blank in the structure that simplexml_load_file returns.
Finally, after hours of trawling google, [...]

Comments (3)

How-To: Parse XML with PHP (SimpleXML)

I’ve been looking for a simple way to convert XML into an array in PHP, like the Perl library XML::Simple does.  The best bet with PHP is SimpleXML, which provides a pretty simple interface for parsing XML in PHP.
Take a simple example XML file:

<list type=’randomlist’>
<item>
<name>Item [...]

Leave a Comment