Bavix Advanced HTML DOM.
- Vendor: bavix
- Package: Advanced HTML DOM
- PHP Version: 7.1+
composer require bavix/advanced-html-dom
The goal of this project is to be a DOM-based drop-in replacement for PHP's simple html dom library.
How To Use - The same way as simple. If you use file/str_get_html then you don't need to change anything. If you are instantiating with
new simple_html_dom() then you will need to change that to
What's Different - Mostly just formatting (spaces) in the html. This is added by DOM and there's no way around it. Some non-standard selectors have been dropped but many more standard ones have been added. For example:
img[src!=foo] was removed because it's not a valid selector. Added are things like
a + b and
a ~ b or even
- 10x-20x Performance increase
- Reduced memory requirement
- Support for many more css selectors
- Supports full set of css pseudo selectors plus many jquery extras:
- Use with css or xpath:
$doc->find('h3 a'), $doc->find('//h3//a')
- Jquery-style functions replace, wrap, unwrap, before after
- Nodeset math:
- Lots of stuff that even BeautifulSoup and Nokogiri can't do:
- Lots more features that haven't been documented yet.
composer req bavix/advanced-html-dom