eelcol/laravel-html-dom
Laravel HTML Dom
A Laravel wrapper around the Dom classes of PHP.
Example
- Load HTML:
$dom = SuperDom::loadHtml('<html-string>');
- Search elements by class
$dom->getElementsByClassname('class', 'element');
$dom->getElementsByClassname(['class1','class2'], 'element');
- Perform a query
This query will find all divs which contains both class1 and class2 class.
$dom->query()
->element('div')
->class('class1')
->class('class2')
->get();
Multiple queries can be combined with or:
$dom->query()
->element('div')
->class('class1')
->class('class2')
->or(function ($q) {
$q->element('ul')
->class('list');
})
->get();
- Perform an XPath query on the document:
$dom->query("a[...]");
- Perform an XPath query on an element:
$elements = $dom->getElementsByTagName("a");
$element = $elements->first();
$element->xpath("....");
- Get the next sibling
$element->getNextSibling();
$element->getNextSibling("span");
Installation
Require this package with composer.
composer require eelcol/laravel-html-dom:^2.0
Related Packages
sorge-it/phpunit-pest-html-assertions
HTML assertions for PHPUnit and Pest: check rendered HTML with CSS selectors, ne...
38
0
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 2.0.4 | ^8.0 | ^9| | MIT | |
| 2.0.3 | ^8.0 | ^9| | MIT | |
| 2.0.2 | ^8.0 | ^9| | MIT | |
| 2.0.1 | ^8.0 | ^9| | MIT | |
| 2.0 | ^8.0 | ^9| | MIT | |
| 1.1.2 | ^8.0 | ^8| | MIT | |
| 1.1.1 | ^8.0 | ^8| | MIT | |
| 1.1.0 | ^8.0 | ^8 | MIT | |
| 1.0.8 | ^7.3.0| | ^8 | MIT | |
| 1.0.7 | ^7.3.0 | ^8 | MIT | |
| 1.0.6 | ^7.3.0 | ^8 | MIT | |
| 1.0.5 | ^7.3.0 | ^8 | MIT | |
| 1.0.4 | ^7.3.0 | ^8 | MIT | |
| 1.0.3 | ^7.3.0 | ^8 | MIT | |
| 1.0.2 | ^7.3.0 | ^8 | MIT | |
| 1.0.1 | ^7.3.0 | ^8 | MIT | |
| 1.0.0 | ^7.3.0 | ^8 | MIT |