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

NAME

6       Mojo::DOM::HTML - HTML/XML engine
7

SYNOPSIS

9         use Mojo::DOM::HTML;
10
11         # Turn HTML into DOM tree
12         my $html = Mojo::DOM::HTML->new;
13         $html->parse('<div><p id="a">Test</p><p id="b">123</p></div>');
14         my $tree = $html->tree;
15

DESCRIPTION

17       Mojo::DOM::HTML is the HTML/XML engine used by Mojo::DOM, based on the
18       HTML Living Standard <https://html.spec.whatwg.org> and the Extensible
19       Markup Language (XML) 1.0 <http://www.w3.org/TR/xml/>.
20

FUNCTIONS

22       Mojo::DOM::HTML implements the following functions, which can be
23       imported individually.
24
25   tag_to_html
26         my $str = tag_to_html 'div', id => 'foo', 'safe content';
27
28       Generate HTML/XML tag and render it right away. This is a significantly
29       faster alternative to "tag" for template systems that have to generate
30       a lot of tags.
31

ATTRIBUTES

33       Mojo::DOM::HTML implements the following attributes.
34
35   tree
36         my $tree = $html->tree;
37         $html    = $html->tree(['root']);
38
39       Document Object Model. Note that this structure should only be used
40       very carefully since it is very dynamic.
41
42   xml
43         my $bool = $html->xml;
44         $html    = $html->xml($bool);
45
46       Disable HTML semantics in parser and activate case-sensitivity,
47       defaults to auto-detection based on XML declarations.
48

METHODS

50       Mojo::DOM::HTML inherits all methods from Mojo::Base and implements the
51       following new ones.
52
53   parse
54         $html = $html->parse('<foo bar="baz">I ♥ Mojolicious!</foo>');
55
56       Parse HTML/XML fragment.
57
58   render
59         my $str = $html->render;
60
61       Render DOM to HTML/XML.
62
63   tag
64         $html = $html->tag('div', id => 'foo', 'safe content');
65
66       Generate HTML/XML tag.
67

SEE ALSO

69       Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.
70
71
72
73perl v5.28.0                      2018-09-25                Mojo::DOM::HTML(3)
Impressum