the PHP library makes me sad sometimes, like earlier tonight.
I've been working on the blog engine, trying to figure out how to get various bits of markup working that I don't want to have to write by hand every post1, and it requires doing XML manipulation in PHP.
if you take the time to look around on the internet (and I did), you'll see a lot of people who want to manipulate HTML or XML in PHP, and all the replies recommend things like SimpleXML, which can't remove or change tags, or DOM, which also didn't work for my needs2. exhausting these options, every thread ends with "use str_replace" or "use preg_replace". sigh. what's the point in having these libraries if they're not actually useful?
I want to do this right, damnit, and I'm going to use a tool that parses my pseudo-HTML fragments into a tree and allows me to add, change, or remove tags at will!
luckily, as I was resigning myself to writing a library from scratch, I discovered simplehtmldom. unlike other libraries I've tried using recently, simplehtmldom worked right out of the box with no issues whatsoever. code example follows.
this code is pulled directly from the footnotes parser of this blog engine, rev 0:
less painful than I expected it would be! hooray!