Hi,
> * Does anyone have any applications that actually /move/ nodes around
> in a tree of HTML::Element objects? As opposed to simply taking the
> structure HTML::TreeBuilder gives you, and traversing it, but never
> changing it?
Yes.
Well, currently, I'm not using the official HTML::Element or
HTML::TreeBuilder at all, but a personal variant (FSHTML::*),
I wrote myself 2-3 years ago.
The main differences to the offical release back then:
* I added support for Comments.
Therefore, I split HTML::Element into two classes:
- HTML::Elem as common base class for HTML::Element and
HTML::Comment. It handles the '_parent' data and the
functoinality as entry in the conntents array of a
HTML::Element.
- HTML::Element handles the tag name, attributes and the contents part.
* some syntax tables were changed to my needs
* a configurable but very slow HTML::PrettyPrinter
to write intended Markup
* some additional functions to traverse and modify the
content of an HTML::Element, e.g. splice
I would like to switch back to the official versions if they meet
my requirements, especially the preservation of comments in the tree.
(Thus, I wouldn't object you changing the internal structure of
HTML::Element. I have to rewrite my code anyway.)
> * Does anyone do /anything/ with HTML::Element trees, aside from
> traversing the tree and read attributes off of nodes? If so, do tell.
Changing/setting/deleting attributes.
Adding/moving/removing elements.
Write HTML.
> * In short, what do you all use TreeBuilder for?
1) As input for my pretty printer
2) For offline checks and manipulation of existing HTML pages
There I read the HTML files, do some checks, update some URLs,
modify the markup (e.g. add classes for stylesheets, add or
replace elements in the navigation bar, adapt pages to new templates)
and write the stuff back.
Ciao, Claus