问题
How can I workaround advanced_html_dom.php str_get_html's conversion of HTML entities, short of applying htmlentities() on every element content?
Despite
http://archive.is/YWKYp#selection-971.0-979.95
The goal of this project is to be a DOM-based drop-in replacement for PHP's simple html dom library.
... If you use file/str_get_html then you don't need to change anything.
I find on
include 'simple_html_dom.php';
$set = str_get_html('<html><title> </title></html>');
echo ($set->find('title',0)->innertext)."\n"; // Expected: Observed:
changing to advanced HTML DOM gives an incompatible result:
include 'advanced_html_dom.php';
$set = str_get_html('<html><title> </title></html>');
echo ($set->find('title',0)->innertext)."\n"; // Expected: Observed: -á
This issue is not confined to spaces.
$set = str_get_html('<html><body>•</body></html>');
echo $set->find('body',0)->innertext; // Expected $bull; Observed ÔÇó
回答1:
You can check my own package PHPHTMLQuery, it helps you to use PHP to select HTML element using most of CSS3 selectors.
the package works with external links and internal html files too.
Installation
Open your terminal and browse into your project root folder and run
composer require "abdelilahlbardi/phphtmlquery":"@dev"
Documentation
For more informations, please visit the package link: PHPHTMLQuery
来源:https://stackoverflow.com/questions/35277100/how-to-workaround-php-advanced-html-doms-conversion-of-entities