Both libraries use Composer:
"require": { "fluentdom/fluentdom": "5.*", "masterminds/html5": "2.*" }
Read HTML5 into FluentDOM:
$html5 = new Masterminds\HTML5(); $fd = FluentDOM($html5->loadHTML($html));
Or write it:
echo $html5->saveHTML($fd->document);
HTML5-PHP puts the elements into the XHTML namespace. To use XPath expressions, you will need to register a prefix for it:
$html5 = new Masterminds\HTML5(); $fd = FluentDOM($html5->loadHTML($html)); $fd->registerNamespace( 'xhtml', 'http://www.w3.org/1999/xhtml' ); echo $fd->find('//xhtml:p')->text();
No comments:
Post a Comment