How to load from ouput file_get_contentes/curl ?
Closed this issue · 3 comments
fer-ri commented
Hello
as title said, how to do that?.
i try to doing something like this
echo FluentDOM($request->getResponseText())
->find('//title')
->text();
Where $request->getResponseText()
is return from curl, but its give me errors
Warning: DOMDocument::loadXML(): Entity 'eacute' not defined in Entity, line: 6033 in ..vendor\fluentdom\fluentdom\src\FluentDOM\Loader\Xml.php on line 38
Thanks :)
fer-ri commented
I think i find out how to do it
$dom = new FluentDOM\Document();
libxml_use_internal_errors(true);
$dom->loadHTML($request->getResponseText());
libxml_clear_errors();
Then the rest is same :)
Thanks
ThomasWeinert commented
Yes, XML does not know the named HTML entities. But here is a shorter way. The second argument of the load() method from FluentDOM\Query() and the FluentDOM() function is the content type. Just provide it.
echo FluentDOM($request->getResponseText(), 'text/html')
->find('//title')
->text();
Here are several other loaders, too: https://github.com/FluentDOM/FluentDOM/wiki/Loaders
fer-ri commented
@ThomasWeinert Thanks a lot :)