1HTML::DOMbo(3)        User Contributed Perl Documentation       HTML::DOMbo(3)
2
3
4

NAME

6       HTML::DOMbo -- convert between XML::DOM and {XML/HTML}::Element trees
7

SYNOPSIS

9         use HTML::DOMbo;
10         use HTML::TreeBuilder;
11         my $tree = HTML::TreeBuilder->new;
12         $tree->parse_from_file('foo.html');
13         my $dom_tree = $tree->to_XML_DOM;
14         # Now you have a DOM element in $dom_tree!
15

DESCRIPTION

17       This class puts a method into HTML::Element called "to_XML_DOM", and
18       puts into the class XML::DOM::Node two methods, "to_HTML_Element" and
19       "to_XML_Element".
20
21   to_XML_DOM
22       The class HTML::TreeBuilder robustly produces parse trees of HTML, but
23       the trees are made of HTML::Element objects, not W3C DOM objects.  If
24       you want to access a TreeBuilder-made parse tree (in $tree) with a DOM
25       interface, use HTML::DOMbo and then call
26
27         my $dom_tree = $tree->to_XML_DOM;
28
29       This returns a new object of the appropriate class (presumably
30       XML::DOM::Element), in a new DOM document, having the same structure
31       and content as the given HTML::TreeBuilder/Element tree.  If you want
32       the elements to be instantiated against an existing document object,
33       instead call:
34
35         my $dom_tree = $tree->to_XML_DOM($existing_dom_document);
36
37   to_HTML_Element and to_XML_Element
38       This module provides two experimental methods (in the XML::DOM::Node
39       class) called "to_HTML_Element" and "to_XML_Element", which clone a DOM
40       node (or DOM document, or document fragment) as a new HTML::Element or
41       XML::Element object.  You need to have the XML::Element module (from
42       the XML::TreeBuilder dist) installed in order to use the
43       "to_XML_Element" method.
44
45       It is possible for this to throw a fatal exception.  And it it possible
46       for this to return a text string instead (if the DOM node given was a
47       text node).  Moreover, in list context it may return any number of
48       items, if the source object is a document fragment containing more than
49       one top-level node, or no nodes.
50
51       Users are encouraged to report to me any problems (or successes) in
52       using this method.  The behavior of this method may change in response
53       to your requests.
54

SEE ALSO

56       XML::DOM, HTML::TreeBuilder, HTML::Element, XML::Element.
57
59       Copyright 2000 Sean M. Burke.
60
61       This library is free software; you can redistribute it and/or modify it
62       under the same terms as Perl itself.
63

AUTHOR

65       Sean M. Burke, <sburke@cpan.org>
66
67
68
69perl v5.30.1                      2020-01-30                    HTML::DOMbo(3)
Impressum