html 5 is not directly supported by PHPs DOM extension. That means FluentDOM will not understand it either. But here is a solution. html5-PHP is library that can parse html5 into a DOM document.
Both libraries use Composer:
Read html5 into FluentDOM:
Or write it:
html5-PHP puts the elements into the Xhtml namespace. To use XPath expressions, you will need to register a prefix for it:
more
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();
more
{ 0 comments... » FluentDOM + html5 read them below or add one }
Post a Comment