This site is rarely updated. benbrophy.com is more up-to-date. - Ben

SimpleXML

I wanted to take a moment to sing the praises of the SimpleXML functions in PHP 5.

When I did my work on Docwalla I used PHP with the XSLT extension. I got a lot of milage out of XSLT, but after I built a variety of applications of Docwalla (wishlist, link list, transcript and FAQ) I could see that it was a pretty labor intensive.

I decided to revamp the Docwalla wishlist in PHP 5, to try out its new XML capabilities. It's just great - I've parsed wishlist.xml as a nicely formatted HTML page, and created an edit form to edit any of the 'wish' nodes in the XML file. I can do this with about 20% of the code it took me to do the same thing with PHP 4 and XSLT.

It's been a little confusing. It's weird how usually the XML nodes are treated like PHP objects, but once XPath is used they become arrays. And I've had to pay attention to typing - it really matters if a variable is a string or a integer sometimes. But it's fun puzzling it out. I guess that's really why I'm doing it.

Tags:

Comments | 2005-05-24