HTML5
class HTML5 (View source)
This class offers convenience methods for parsing and serializing HTML5.
It is roughly designed to mirror the \DOMDocument class that is provided with most versions of PHP.
EXPERIMENTAL. This may change or be completely replaced.
Methods
No description
Get the default options.
Load and parse an HTML file.
Parse a HTML Document from a string.
Convenience function to load an HTML file.
Parse a HTML fragment from a string.
Return all errors encountered into parsing phase
Return true it some errors were encountered into parsing phase
Save a DOM into a given file as HTML5.
Convert a DOM into an HTML5 string.
Details
at line line 34
__construct(
array $options = array())
at line line 44
array
getOptions()
Get the default options.
at line line 66
DOMDocument
load(
string $file)
Load and parse an HTML file.
This will apply the HTML5 parser, which is tolerant of many varieties of HTML, including XHTML 1, HTML 4, and well-formed HTML 3. Note that in these cases, not all of the old data will be preserved. For example, XHTML's XML declaration will be removed.
The rules governing parsing are set out in the HTML 5 spec.
at line line 90
DOMDocument
loadHTML(
string $string)
Parse a HTML Document from a string.
Take a string of HTML 5 (or earlier) and parse it into a DOMDocument.
at line line 111
DOMDocument
loadHTMLFile(
string $file)
Convenience function to load an HTML file.
This is here to provide backwards compatibility with the PHP DOM implementation. It simply calls load().
at line line 125
DOMDocumentFragment
loadHTMLFragment(
string $string)
Parse a HTML fragment from a string.
at line line 137
array
getErrors()
Return all errors encountered into parsing phase
at line line 147
bool
hasErrors()
Return true it some errors were encountered into parsing phase
at line line 158
parse(
InputStream $input)
Parse an input stream.
Lower-level loading function. This requires an input stream instead of a string, file, or resource.
at line line 177
parseFragment(
InputStream $input)
Parse an input stream where the stream is a fragment.
Lower-level loading function. This requires an input stream instead of a string, file, or resource.
at line line 202
save(
mixed $dom,
string $file,
array $options = array())
Save a DOM into a given file as HTML5.
at line line 235
string
saveHTML(
mixed $dom,
array $options = array())
Convert a DOM into an HTML5 string.