@@ -7,25 +7,23 @@ The component only goal is to convert CSS selectors to their XPath
7
7
equivalents:
8
8
9
9
``` php
10
- use Symfony\Component\CssSelector\CssSelector ;
10
+ use Symfony\Component\CssSelector\CssSelectorConverter ;
11
11
12
- print CssSelector::toXPath('div.item > h4 > a');
12
+ $converter = new CssSelectorConverter();
13
+ print $converter->toXPath('div.item > h4 > a');
13
14
```
14
15
15
16
HTML and XML are different
16
17
--------------------------
17
18
18
19
The ` CssSelector ` component comes with an ` HTML ` extension which is enabled by
19
20
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 ` :
21
+ disable this ` HTML ` extension. That's because, ` HTML ` tag & attribute names are
22
+ always lower-cased, but case-sensitive in ` XML ` :
22
23
23
24
``` php
24
25
// disable `HTML` extension:
25
- CssSelector::disableHtmlExtension();
26
-
27
- // re-enable `HTML` extension:
28
- CssSelector::enableHtmlExtension();
26
+ $converter = new CssSelectorConverter(false);
29
27
```
30
28
31
29
When the ` HTML ` extension is enabled, tag names are lower-cased, attribute
@@ -45,3 +43,42 @@ You can run the unit tests with the following command:
45
43
$ cd path/to/Symfony/Component/CssSelector/
46
44
$ composer install
47
45
$ phpunit
46
+
47
+ License
48
+ -------
49
+
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.
0 commit comments