html5
is an extension for PHP bringing a
fast HTML5 compatible parser to PHP.
function html5_parse(string $html [, string $encoding = "UTF-8" ]) : DOMDocument
<?php
$document = html5_parse('<html>Hello World!</html>');
$document->formatOutput = true;
print($document->saveHTML());
$body = $document->getElementsByTagName('body')[0];
var_dump(get_class($body));
provides
<!DOCTYPE html>
<html>
<head></head>
<body>Hello World!</body>
</html>
string(10) "DOMElement"
- php development package
- libxml2 development package
- myhtml
git clone 'https://github.com/afflerbach/html5.git'
cd html5
phpize
./configure
make
sudo make install
BSD