flippa/errbit-php — pull request #8 by danielbeardsley (2013-03-26 23:36:43+00:00)
Title: Fix XMLBuilder

So, `SimpleXML` **SUCKS**. I've replaced it with `DOMDocument`. Most people advise using `DOMDocument` because `SimpleXML` has so many quirks and limited / broken support for DOM modification.

### The Bug:
I spent several hours futzing with it. Trying to add an Element with no "value" or at least a falsy value ('', 0, null). I was able to get it to add the Element, but it would always mess up the rest of the document. The doc would be wrapped in a base element and the XML version declaration would be at the top.

I added some failing tests before I did anything (`git co 3452b50d2af448ff6c327ad0e3c175374660bf65` and run them to see the broken result). I wasted several hours and lots of frustration trying to get SimpleXML to work in a sensible manner. I even tried rewriting it to use the official api: `addChild()` and `addAttribute()` but that wasn't working either. This now seems to work just fine, and the several are now fixed and tested.