php-extended / php-css-selector-object
A library that implements the php-extended/php-css-selector-interface interface library.
7.0.6
2024-07-31 13:57 UTC
Requires
Requires (Dev)
- dev-master
- 7.0.6
- 7.0.5
- 7.0.4
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 6.0.8
- 6.0.7
- 6.0.6
- 6.0.5
- 6.0.4
- 6.0.3
- 6.0.2
- 6.0.1
- 6.0.0
- 5.0.1
- 5.0.0
- 4.0.1
- 4.0.0
- 3.4.3
- 3.4.2
- 3.4.1
- 3.4.0
- 3.2.5
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.15
- 3.1.14
- 3.1.13
- 3.1.12
- 3.1.11
- 3.1.10
- 3.1.9
- 3.1.8
- 3.1.7
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
This package is auto-updated.
Last update: 2024-10-01 00:14:39 UTC
README
A library that implements the php-extended/php-css-selector-interface interface library.
Installation
The installation of this library is made via composer and the autoloading of all classes of this library is made through their autoloader.
- Download
composer.phar
from their website. - Then run the following command to install this library as dependency :
php composer.phar php-extended/php-css-selector-object ^7
Basic Usage
To build a css-selector tree, just use the collection node and the single nodes :
use PhpExtended\Css\CssAndSelector;
use PhpExtended\Css\CssOrSelector;
use PhpExtended\Css\CssNotSelector;
use PhpExtended\Css\CssAttributeEqualsSelector;
use PhpExtended\Css\CssElementSelector;
use PhpExtended\Css\CssStateSelector;
$s = new CssElementSelector('p'); // p
$s = new CssAndSelector($s, new CssAttributeEqualsSelector('class', 'foo')); // p.foo
$s2 = new CssAttributeEqualsSelector('id', 'bar'); // #bar
$s2 = new CssAndSelector($s2, new CssAttributeEqualsSelector('data-target', 'foobar')); // #bar[data-target=foobar]
$s = new CssNotSelector($s, new CssAttributeEqualsSelector('class', 'boo')); // p.foo:not(.boo)
$s = new CssOrSelector($s, $s2); // p.foo:not(.boo), #bar[data-target=foobar]
To parse css selector data, do the following :
use PhpExtended\Css\CssSelectorParser;
$parser = new CssSelectorParser();
$node = $parser->parse('div p:not(.foo)');
// $node is now a CssAbstractSelectorInterface
License
MIT (See license file).