HTML::DOMbo(3) User Contributed Perl Documentation HTML::DOMbo(3)NAMEHTML::DOMbo-- convert between XML::DOM and {XML/HTML}::Element trees
SYNOPSIS
use HTML::DOMbo;
use HTML::TreeBuilder;
my $tree = HTML::TreeBuilder->new;
$tree->parse_from_file('foo.html');
my $dom_tree = $tree->to_XML_DOM;
# Now you have a DOM element in $dom_tree!
DESCRIPTION
This class puts a method into HTML::Element called "to_XML_DOM", and
puts into the class XML::DOM::Node two methods, "to_HTML_Element" and
"to_XML_Element".
to_XML_DOM
The class HTML::TreeBuilder robustly produces parse trees of HTML, but
the trees are made of HTML::Element objects, not W3C DOM objects. If
you want to access a TreeBuilder-made parse tree (in $tree) with a DOM
interface, use HTML::DOMbo and then call
my $dom_tree = $tree->to_XML_DOM;
This returns a new object of the appropriate class (presumably
XML::DOM::Element), in a new DOM document, having the same structure
and content as the given HTML::TreeBuilder/Element tree. If you want
the elements to be instantiated against an existing document object,
instead call:
my $dom_tree = $tree->to_XML_DOM($existing_dom_document);
to_HTML_Element and to_XML_Element
This module provides two experimental methods (in the XML::DOM::Node
class) called "to_HTML_Element" and "to_XML_Element", which clone a DOM
node (or DOM document, or document fragment) as a new HTML::Element or
XML::Element object. You need to have the XML::Element module (from
the XML::TreeBuilder dist) installed in order to use the
"to_XML_Element" method.
It is possible for this to throw a fatal exception. And it it possible
for this to return a text string instead (if the DOM node given was a
text node). Moreover, in list context it may return any number of
items, if the source object is a document fragment containing more than
one top-level node, or no nodes.
Users are encouraged to report to me any problems (or successes) in
using this method. The behavior of this method may change in response
to your requests.
SEE ALSO
XML::DOM, HTML::TreeBuilder, HTML::Element, XML::Element.
COPYRIGHT
Copyright 2000 Sean M. Burke.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
AUTHOR
Sean M. Burke, <sburke@cpan.org>
perl v5.14.1 2005-01-05 HTML::DOMbo(3)