I sat down earlier to have a play around with SimpleXML, the new PHP5 feature that allows easy access to data structures within an XML document. I had also been looking at the ma.gnolia API earlier to implement support for importing bookmarks from ma.gnolia to my bookmarking application urlmarkr. So I decided to write a sidebar widget to display bookmarks from ma.gnolia in the Wordpress sidebar.
Thanks to the power of SimpleXML, what would have taken possibly 10-20 lines of code before, simply took 4 or 5! I used the Snoopy PHP class to fetch the request from ma.gnolia. It’s then just a simple case of calling simplexml_load_string. It’s then just a case of iterating through the XML data using a simple foreach statement just like it was a collection of arrays.
The end result is the ma.gnolia sidebar widget. More time was spent in writing this post than in writing the widget such is the power of SimpleXML. You can grab the download if your interested from here.






