1 |
=head1 NAME |
=head1 NAME |
2 |
|
|
3 |
What::HTML - An HTML Parser |
Whatpm::HTML - An HTML Parser |
4 |
|
|
5 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
6 |
|
|
7 |
use What::HTML; |
use Whatpm::HTML; |
8 |
|
|
9 |
my $s = q<<!DOCTYPE html><html>...</html>>; |
my $s = q<<!DOCTYPE html><html>...</html>>; |
10 |
# $doc = an empty DOM |Document| object |
# $doc = an empty DOM |Document| object |
13 |
warn $error_code, "\n"; |
warn $error_code, "\n"; |
14 |
}; |
}; |
15 |
|
|
16 |
What::HTML->parse_string ($s => $doc, $onerror); |
Whatpm::HTML->parse_string ($s => $doc, $onerror); |
17 |
|
|
18 |
## Then, |$doc| is the DOM representation of |$s|. |
## Then, |$doc| is the DOM representation of |$s|. |
19 |
|
|
20 |
=head1 DESCRIPTION |
=head1 DESCRIPTION |
21 |
|
|
22 |
The C<What::HTML> module contains HTML parser and serializer. |
The C<Whatpm::HTML> module contains HTML parser and serializer. |
23 |
|
|
24 |
The HTML parser can be used to construct the DOM tree representation |
The HTML parser can be used to construct the DOM tree representation |
25 |
from an HTML document. The parsing and tree construction are done |
from an HTML document. The parsing and tree construction are done |
30 |
is performed as described in the Web Applications 1.0 specification |
is performed as described in the Web Applications 1.0 specification |
31 |
for C<innerHTML> DOM attribute. |
for C<innerHTML> DOM attribute. |
32 |
|
|
33 |
This module is part of WHAT.pm - Perl Modules for |
This module is part of Whatpm - Perl Modules for |
34 |
Web Hypertext Application Technologies. |
Web Hypertext Application Technologies. |
35 |
|
|
36 |
=head1 METHODS |
=head1 METHODS |
37 |
|
|
38 |
=over 4 |
=over 4 |
39 |
|
|
40 |
=item [I<$doc> =] What::HTML->parse_string (I<$s>, I<$doc>[, I<$onerror>]); |
=item [I<$doc> =] Whatpm::HTML->parse_string (I<$s>, I<$doc>[, I<$onerror>]); |
41 |
|
|
42 |
Parse a string I<$s> as an HTML document. |
Parse a string I<$s> as an HTML document. |
43 |
|
|
61 |
|
|
62 |
The method returns the DOM C<Document> object (i.e. the second argument). |
The method returns the DOM C<Document> object (i.e. the second argument). |
63 |
|
|
64 |
Note that the C<What::NanoDOM> module provides a non-conforming |
Note that the C<Whatpm::NanoDOM> module provides a non-conforming |
65 |
implementation of DOM that only implements the subset that |
implementation of DOM that only implements the subset that |
66 |
is necessary for the purpose of C<What::HTML>'s parsing and |
is necessary for the purpose of C<Whatpm::HTML>'s parsing and |
67 |
serializing. |
serializing. |
68 |
With this module, creating a new HTML C<Document> object |
With this module, creating a new HTML C<Document> object |
69 |
from a string containing HTML document can be coded as: |
from a string containing HTML document can be coded as: |
70 |
|
|
71 |
use What::HTML; |
use Whatpm::HTML; |
72 |
use What::NanoDOM; |
use Whatpm::NanoDOM; |
73 |
my $doc = What::HTML->parse_string |
my $doc = Whatpm::HTML->parse_string |
74 |
($s => What::NanoDOM::Document->new, $onerror); |
($s => Whatpm::NanoDOM::Document->new, $onerror); |
75 |
|
|
76 |
=item I<$s> = What::HTML->get_inner_html (I<$node>[, I<$onerror>]); |
=item I<$s> = Whatpm::HTML->get_inner_html (I<$node>[, I<$onerror>]); |
77 |
|
|
78 |
Return the HTML serialization of a DOM node I<$node>. |
Return the HTML serialization of a DOM node I<$node>. |
79 |
|
|
113 |
Web Applications 1.0 Working Draft (aka HTML5) |
Web Applications 1.0 Working Draft (aka HTML5) |
114 |
<http://whatwg.org/html5>. (Revision 792, 1 May 2007) |
<http://whatwg.org/html5>. (Revision 792, 1 May 2007) |
115 |
|
|
116 |
L<What::NanoDOM> |
L<Whatpm::NanoDOM> |
117 |
|
|
118 |
=head1 AUTHOR |
=head1 AUTHOR |
119 |
|
|