today i wrote a stripped down html generator (in php, of course). there’s got a be a jazzier word than generator. you know something that’s the opposite of a parser. something that models and spits out a tree.
it has the ability to generate a single HTML tag with attributes and optionally some content and an end tag. like this:
<acronym title="mainstream media">msm</acronym>
<img src="some_image.jpg" />
that’s it. in all its glory. seems totally worthless, huh? but the beauty is that it can represent any tag (element actually) with any attributes (in other words it will create well-formed but not valid html). so it’s pretty flexible.
and the contents (“msm” in the first example above) can be either text and/or other elements which can in turn contain text and/or other elements. so i can use it to model a whole webpage, since every webpage is at the root composed of a single html element:
<html>justin <em>blathering</em> about some techie junk</html>
it’s kind of modeled on my rudimentary understanding of the dom with a much simpler/cleaner interface. it doesn’t have any fancy tree traversing methods yet but i’m getting there.
anyway, here’s the code: HTMLElement.phps.