You can use zendframework/zend-dom as a standalone component. It has no external dependencies, which means that it does not need another Zend component or another library.
Alternatively, you can also use a library completely unrelated to Zend, like tburry/pquery or my PHPPowertools/DOM-Query . Both libraries perform the same functions as zendframework/zend-dom , but the syntax is different and HTML5 support may vary for each library.
Example:
This example shows how you load an HTML string and a query for .foo .bar a from each of these three libraries:
Using zendframework/zend-dom , you will do the following:
use \Zend\Dom\Query; $dom = new Query($htmlcode); $results = $dom->execute('.foo .bar a');
Using tburry/pquery you will do the following:
use \pQuery\pQuery $dom = pQuery::parseStr($htmlcode); $dom->query('.foo .bar a');
Using PHPPowertools/DOM-Query , you will do the following:
use \PowerTools\DOM_Query $H = new DOM_Query($htmlcode); $s = $H->select('.foo .bar a');
Choose your poison!
source share