Download the PHP package mima/dom-navigator without Composer
On this page you can find all versions of the php package mima/dom-navigator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mima/dom-navigator
More information about mima/dom-navigator
Files in mima/dom-navigator
Package dom-navigator
Short Description Simple wrapper for find elements in DOMNode. Adds XPath, Selector (like jQuery) mechanism to find elements, allow create own implementation.
License MIT
Informations about the package dom-navigator
PHP DOMNavigator
About library
The library is a wrapper for the implementation of DOM in php. Designed for easy loading html document, parse it. It allows you to implement your own algorithm search elements.
Documentation
- Installation
- Use Navigator
- Create custom Finder
- Create custom Loader
- Use CompositeLoader
Installation
Run command:
composer require mima/dom-navigator
Add dependency on your composer.json:
Use Navigator
For beginning usage navigator need create an instance of DOMNavigator\Navigator
class:
Before search in document need load document:
When you call method loadHTML
or loadXML
, navigator try to load DOMDocument
with help DOMNavigator\Loader\StringLoader
(in this example).
After loading you may use navigate method for search elements in document.
Navigate method always return \DOMNodeList. It is possible to search in the context of an element:
If you want find out number of found elements, follow to this example:
Create custom Finder
All finders need implement interface DOMNavigator\Finder\FinderInterface
.
Create custom Loader
All loaders need implement DOMNavigator\Finder\LoaderInterface
.
Use CompositeLoader
If you are not sure of the source through the document, you can use CompositeLoader:
The next step is assigning the loader in the navigator: