|
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\CssSelectorConverter; |
11 |
| - |
12 |
| -$converter = new CssSelectorConverter(); |
13 |
| -print $converter->toXPath('div.item > h4 > a'); |
14 |
| -``` |
15 |
| - |
16 |
| -HTML and XML are different |
17 |
| --------------------------- |
18 |
| - |
19 |
| -The `CssSelector` component comes with an `HTML` extension which is enabled by |
20 |
| -default. If you need to use this component with `XML` documents, you have to |
21 |
| -disable this `HTML` extension. That's because, `HTML` tag & attribute names are |
22 |
| -always lower-cased, but case-sensitive in `XML`: |
23 |
| - |
24 |
| -```php |
25 |
| -// disable `HTML` extension: |
26 |
| -$converter = new CssSelectorConverter(false); |
27 |
| -``` |
28 |
| - |
29 |
| -When the `HTML` extension is enabled, tag names are lower-cased, attribute |
30 |
| -names are lower-cased, the following extra pseudo-classes are supported: |
31 |
| -`checked`, `link`, `disabled`, `enabled`, `selected`, `invalid`, `hover`, |
32 |
| -`visited`, and the `lang()` function is also added. |
| 4 | +The CssSelector component converts CSS selectors to XPath expressions. |
33 | 5 |
|
34 | 6 | Resources
|
35 | 7 | ---------
|
36 | 8 |
|
37 |
| -This component is a port of the Python cssselect library |
38 |
| -[v0.7.1](https://github.com/SimonSapin/cssselect/releases/tag/v0.7.1), |
39 |
| -which is distributed under the BSD license. |
40 |
| - |
41 |
| -You can run the unit tests with the following command: |
| 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) |
42 | 14 |
|
43 |
| - $ cd path/to/Symfony/Component/CssSelector/ |
44 |
| - $ composer install |
45 |
| - $ phpunit |
46 |
| - |
47 |
| -License |
| 15 | +Credits |
48 | 16 | -------
|
49 | 17 |
|
50 |
| -This component is a port of the Python cssselect library, |
51 |
| -which is copyright Ian Bicking, https://github.com/SimonSapin/cssselect. |
52 |
| - |
53 |
| -Copyright (c) 2007-2012 Ian Bicking and contributors. See AUTHORS |
54 |
| -for more details. |
55 |
| - |
56 |
| -All rights reserved. |
57 |
| - |
58 |
| -Redistribution and use in source and binary forms, with or without |
59 |
| -modification, are permitted provided that the following conditions are |
60 |
| -met: |
61 |
| - |
62 |
| -1. Redistributions of source code must retain the above copyright |
63 |
| -notice, this list of conditions and the following disclaimer. |
64 |
| - |
65 |
| -2. Redistributions in binary form must reproduce the above copyright |
66 |
| -notice, this list of conditions and the following disclaimer in |
67 |
| -the documentation and/or other materials provided with the |
68 |
| -distribution. |
69 |
| - |
70 |
| -3. Neither the name of Ian Bicking nor the names of its contributors may |
71 |
| -be used to endorse or promote products derived from this software |
72 |
| -without specific prior written permission. |
73 |
| - |
74 |
| -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
75 |
| -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
76 |
| -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
77 |
| -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IAN BICKING OR |
78 |
| -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
79 |
| -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
80 |
| -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
81 |
| -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
82 |
| -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
83 |
| -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
84 |
| -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 18 | +This component is a port of the Python cssselect library |
| 19 | +[v0.7.1](https://github.com/SimonSapin/cssselect/releases/tag/v0.7.1), |
| 20 | +which is distributed under the BSD license. |
0 commit comments