|
1 | 1 | CssSelector Component |
2 | 2 | ===================== |
3 | 3 |
|
4 | | -CssSelector converts CSS selectors to XPath expressions. |
5 | | - |
6 | | -The component only goal is to convert CSS selectors to their XPath |
7 | | -equivalents: |
8 | | - |
9 | | -```php |
10 | | -use Symfony\Component\CssSelector\CssSelector; |
11 | | - |
12 | | -print CssSelector::toXPath('div.item > h4 > a'); |
13 | | -``` |
14 | | - |
15 | | -HTML and XML are different |
16 | | --------------------------- |
17 | | - |
18 | | -The `CssSelector` component comes with an `HTML` extension which is enabled by |
19 | | -default. If you need to use this component with `XML` documents, you have to |
20 | | -disable this `HTML` extension. That's because, `HTML` tag & attribute names |
21 | | -are always lower-cased, but case-sensitive in `XML`: |
22 | | - |
23 | | -```php |
24 | | -// disable `HTML` extension: |
25 | | -CssSelector::disableHtmlExtension(); |
26 | | - |
27 | | -// re-enable `HTML` extension: |
28 | | -CssSelector::enableHtmlExtension(); |
29 | | -``` |
30 | | - |
31 | | -When the `HTML` extension is enabled, tag names are lower-cased, attribute |
32 | | -names are lower-cased, the following extra pseudo-classes are supported: |
33 | | -`checked`, `link`, `disabled`, `enabled`, `selected`, `invalid`, `hover`, |
34 | | -`visited`, and the `lang()` function is also added. |
| 4 | +The CssSelector component converts CSS selectors to XPath expressions. |
35 | 5 |
|
36 | 6 | Resources |
37 | 7 | --------- |
38 | 8 |
|
| 9 | + * [Documentation](https://symfony.com/doc/current/components/css_selector.html) |
| 10 | + * [Contributing](https://symfony.com/doc/current/contributing/index.html) |
| 11 | + * [Report issues](https://github.com/symfony/symfony/issues) and |
| 12 | + [send Pull Requests](https://github.com/symfony/symfony/pulls) |
| 13 | + in the [main Symfony repository](https://github.com/symfony/symfony) |
| 14 | + |
| 15 | +Credits |
| 16 | +------- |
| 17 | + |
39 | 18 | This component is a port of the Python cssselect library |
40 | 19 | [v0.7.1](https://github.com/SimonSapin/cssselect/releases/tag/v0.7.1), |
41 | 20 | which is distributed under the BSD license. |
42 | | - |
43 | | -You can run the unit tests with the following command: |
44 | | - |
45 | | - $ cd path/to/Symfony/Component/CssSelector/ |
46 | | - $ composer install |
47 | | - $ phpunit |
0 commit comments