Html5
class Html5
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.
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
Parse an input stream where the stream is a fragment.
Save a DOM into a given file as HTML5.
Convert a DOM into an HTML5 string.
Details
at line line 33
__construct(
array $options = array())
at line line 43
array
getOptions()
Get the default options.
at line line 67
DOMDocument
load(
string $file,
array $options = array())
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 93
DOMDocument
loadHTML(
string $string,
array $options = array())
Parse a HTML Document from a string.
Take a string of HTML 5 (or earlier) and parse it into a DOMDocument.
at line line 116
DOMDocument
loadHTMLFile(
string $file,
array $options = array())
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 132
DOMDocumentFragment
loadHTMLFragment(
string $string,
array $options = array())
Parse a HTML fragment from a string.
at line line 144
array
getErrors()
Return all errors encountered into parsing phase
at line line 154
bool
hasErrors()
Return true it some errors were encountered into parsing phase
at line line 165
parse(
InputStream $input,
array $options = array())
Parse an input stream.
Lower-level loading function. This requires an input stream instead of a string, file, or resource.
at line line 184
parseFragment(
InputStream $input,
array $options = array())
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 209
save(
mixed $dom,
string|resource $file,
array $options = array())
Save a DOM into a given file as HTML5.
at line line 242
string
saveHTML(
mixed $dom,
array $options = array())
Convert a DOM into an HTML5 string.