php-extended/php-css-selector-object
最新稳定版本:8.0.10
Composer 安装命令:
composer require php-extended/php-css-selector-object
包简介
A library that implements the php-extended/php-css-selector-interface interface library.
README 文档
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.pharfrom their website. - Then run the following command to install this library as dependency :
php composer.phar php-extended/php-css-selector-object ^8
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).
统计信息
- 总下载量: 38.05k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-23