1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
2 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
3 |
<head> |
<head> |
4 |
<title>What::HTML - An HTML Parser</title> |
<title>Whatpm::HTML - An HTML Parser</title> |
5 |
<link rel="stylesheet" href="http://suika.fam.cx/www/style/html/pod.css" type="text/css" /> |
<link rel="stylesheet" href="http://suika.fam.cx/www/style/html/pod.css" type="text/css" /> |
6 |
<link rev="made" href="mailto:admin@suika.fam.cx" /> |
<link rev="made" href="mailto:admin@suika.fam.cx" /> |
7 |
</head> |
</head> |
28 |
<p> |
<p> |
29 |
</p> |
</p> |
30 |
<h1><a name="name">NAME</a></h1> |
<h1><a name="name">NAME</a></h1> |
31 |
<p>What::HTML - An HTML Parser</p> |
<p>Whatpm::HTML - An HTML Parser</p> |
32 |
<p> |
<p> |
33 |
</p> |
</p> |
34 |
<hr /> |
<hr /> |
35 |
<h1><a name="synopsis">SYNOPSIS</a></h1> |
<h1><a name="synopsis">SYNOPSIS</a></h1> |
36 |
<pre> |
<pre> |
37 |
use What::HTML; |
use Whatpm::HTML; |
38 |
|
|
39 |
my $s = q<<!DOCTYPE html><html>...</html>>; |
my $s = q<<!DOCTYPE html><html>...</html>>; |
40 |
# $doc = an empty DOM |Document| object |
# $doc = an empty DOM |Document| object |
43 |
warn $error_code, "\n"; |
warn $error_code, "\n"; |
44 |
}; |
}; |
45 |
|
|
46 |
What::HTML->parse_string ($s => $doc, $onerror); |
Whatpm::HTML->parse_string ($s => $doc, $onerror); |
47 |
|
|
48 |
## Then, |$doc| is the DOM representation of |$s|.</pre> |
## Then, |$doc| is the DOM representation of |$s|.</pre> |
49 |
<p> |
<p> |
50 |
</p> |
</p> |
51 |
<hr /> |
<hr /> |
52 |
<h1><a name="description">DESCRIPTION</a></h1> |
<h1><a name="description">DESCRIPTION</a></h1> |
53 |
<p>The <code>What::HTML</code> module contains HTML parser and serializer.</p> |
<p>The <code>Whatpm::HTML</code> module contains HTML parser and serializer.</p> |
54 |
<p>The HTML parser can be used to construct the DOM tree representation |
<p>The HTML parser can be used to construct the DOM tree representation |
55 |
from an HTML document. The parsing and tree construction are done |
from an HTML document. The parsing and tree construction are done |
56 |
as described in the Web Application 1.0 specification.</p> |
as described in the Web Application 1.0 specification.</p> |
58 |
of a DOM tree (or a tree fragment thereof). The serialization |
of a DOM tree (or a tree fragment thereof). The serialization |
59 |
is performed as described in the Web Applications 1.0 specification |
is performed as described in the Web Applications 1.0 specification |
60 |
for <code>innerHTML</code> DOM attribute.</p> |
for <code>innerHTML</code> DOM attribute.</p> |
61 |
<p>This module is part of WHAT.pm - Perl Modules for |
<p>This module is part of Whatpm - Perl Modules for |
62 |
Web Hypertext Application Technologies.</p> |
Web Hypertext Application Technologies.</p> |
63 |
<p> |
<p> |
64 |
</p> |
</p> |
65 |
<hr /> |
<hr /> |
66 |
<h1><a name="methods">METHODS</a></h1> |
<h1><a name="methods">METHODS</a></h1> |
67 |
<dl> |
<dl> |
68 |
<dt><strong><a name="item_parse_string">[<em>$doc</em> =] What::HTML->parse_string (<em>$s</em>, <em>$doc</em>[, <em>$onerror</em>]);</a></strong><br /> |
<dt><strong><a name="item_parse_string">[<em>$doc</em> =] Whatpm::HTML->parse_string (<em>$s</em>, <em>$doc</em>[, <em>$onerror</em>]);</a></strong><br /> |
69 |
</dt> |
</dt> |
70 |
<dd> |
<dd> |
71 |
Parse a string <em>$s</em> as an HTML document. |
Parse a string <em>$s</em> as an HTML document. |
92 |
parse error makes that string being <code>warn</code>ed.</p> |
parse error makes that string being <code>warn</code>ed.</p> |
93 |
</dd> |
</dd> |
94 |
<dd> |
<dd> |
95 |
|
<p><strong>NOTE</strong>: To be a conforming user agent, the code MUST either |
96 |
|
abort the processing by throwing an exception at the first |
97 |
|
invocation or MUST continue the processing until the parser |
98 |
|
stops.</p> |
99 |
|
</dd> |
100 |
|
<dd> |
101 |
<p>The method returns the DOM <code>Document</code> object (i.e. the second argument).</p> |
<p>The method returns the DOM <code>Document</code> object (i.e. the second argument).</p> |
102 |
</dd> |
</dd> |
103 |
<dd> |
<dd> |
104 |
<p>Note that the <code>What::NanoDOM</code> module provides a non-conforming |
<p>Note that the <code>Whatpm::NanoDOM</code> module provides a non-conforming |
105 |
implementation of DOM that only implements the subset that |
implementation of DOM that only implements a subset that |
106 |
is necessary for the purpose of <code>What::HTML</code>'s parsing and |
is necessary for the purpose of <code>Whatpm::HTML</code>'s parsing and |
107 |
serializing. |
serializing. |
108 |
With this module, creating a new HTML <code>Document</code> object |
With this module, creating a new HTML <code>Document</code> object |
109 |
from a string containing HTML document can be coded as:</p> |
from a string containing HTML document might be coded as:</p> |
110 |
</dd> |
</dd> |
111 |
<dd> |
<dd> |
112 |
<pre> |
<pre> |
113 |
use What::HTML; |
use Whatpm::HTML; |
114 |
use What::NanoDOM; |
use Whatpm::NanoDOM; |
115 |
my $doc = What::HTML->parse_string ($s => What::NanoDOM->new, $onerror);</pre> |
my $doc = Whatpm::HTML->parse_string |
116 |
|
($s => Whatpm::NanoDOM::Document->new, $onerror);</pre> |
117 |
</dd> |
</dd> |
118 |
<p></p> |
<p></p> |
119 |
<dt><strong><a name="item_get_inner_html"><em>$s</em> = What::HTML->get_inner_html (<em>$node</em>[, <em>$onerror</em>]);</a></strong><br /> |
<dt><strong><a name="item_get_inner_html"><em>$s</em> = Whatpm::HTML->get_inner_html (<em>$node</em>[, <em>$onerror</em>]);</a></strong><br /> |
120 |
</dt> |
</dt> |
121 |
<dd> |
<dd> |
122 |
Return the HTML serialization of a DOM node <em>$node</em>. |
Return the HTML serialization of a DOM node <em>$node</em>. |
123 |
</dd> |
</dd> |
124 |
<dd> |
<dd> |
125 |
<p>The first argument, <em>$node</em>, MUST be a DOM <code>Document</code>, |
<p>The first argument, <em>$node</em>, MUST be a DOM <code>Document</code>, |
126 |
<code>Node</code>, or <code>DocumentFragment</code> object.</p> |
<code>Element</code>, or <code>DocumentFragment</code> node.</p> |
127 |
</dd> |
</dd> |
128 |
<dd> |
<dd> |
129 |
<p>The second argument, <em>$onerror</em>, MUST be a reference to the |
<p>The second argument, <em>$onerror</em>, MUST be a reference to the |
130 |
error handling code. This code will be invoked if a descendant |
error handling code. This code will be invoked if a descendant |
131 |
of <code>$node</code> is not of <code>Element</code>, <code>Text</code>, <code>CDATASection</code>, |
of <em>$node</em> is neither of <code>Element</code>, <code>Text</code>, <code>CDATASection</code>, |
132 |
<code>Comment</code>, <code>DocumentType</code>, or <code>EntityReference</code> so |
<code>Comment</code>, <code>DocumentType</code>, nor <code>EntityReference</code>, so |
133 |
that <code>INVALID_STATE_ERR</code> MUST be thrown. |
that an <code>INVALID_STATE_ERR</code> exception MUST be thrown. |
134 |
The code will be invoked with an argument, which is the node |
The code will be invoked with an argument, which is the node |
135 |
whose type is invalid. |
whose type is invalid. |
136 |
This argument is optional; if missing, any such |
The argument <em>$onerror</em> is optional; if missing, any erroneous |
137 |
node is simply ignored.</p> |
node is simply ignored.</p> |
138 |
</dd> |
</dd> |
139 |
<dd> |
<dd> |
140 |
<p>The method returns the <code>inner_html</code> attribute |
<p>The method returns a reference to the <code>inner_html</code> attribute |
141 |
value, i.e. the HTML serialization of the <code>$node</code>.</p> |
value, i.e. the HTML serialization of the <em>$node</em>.</p> |
142 |
</dd> |
</dd> |
143 |
<p></p></dl> |
<p></p></dl> |
144 |
<p> |
<p> |
149 |
to improve performance.</p> |
to improve performance.</p> |
150 |
<p>A method that accepts a byte stream as an input.</p> |
<p>A method that accepts a byte stream as an input.</p> |
151 |
<p>Charset detection algorithm.</p> |
<p>Charset detection algorithm.</p> |
152 |
<p>Setting inner_html.</p> |
<p>Documentation for the setter of inner_html.</p> |
153 |
<p>And there are many ``TODO''s and ``ISSUE''s in the source code.</p> |
<p>And there are many ``TODO''s and ``ISSUE''s in the source code.</p> |
154 |
<p> |
<p> |
155 |
</p> |
</p> |
156 |
<hr /> |
<hr /> |
157 |
<h1><a name="see_also">SEE ALSO</a></h1> |
<h1><a name="see_also">SEE ALSO</a></h1> |
158 |
|
<p>Whatpm |
159 |
|
<http://suika.fam.cx/www/markup/html/whatpm/readme></p> |
160 |
<p>Web Applications 1.0 Working Draft (aka HTML5) |
<p>Web Applications 1.0 Working Draft (aka HTML5) |
161 |
<http://whatwg.org/html5>. (Revision 792, 1 May 2007)</p> |
<http://whatwg.org/html5>. (Revision 792, 1 May 2007)</p> |
162 |
<p><a href="../What/NanoDOM.html">the What::NanoDOM manpage</a></p> |
<p><a href="../Whatpm/NanoDOM.html">the Whatpm::NanoDOM manpage</a></p> |
163 |
<p> |
<p> |
164 |
</p> |
</p> |
165 |
<hr /> |
<hr /> |