1d45ca894b
* 2.6: (21 commits) [FrameworkBundle] Fix title and placeholder rendering in php form templates. [TwigBridge] Removed duplicated code from TwigRenderer [Translator][Logging] implement TranslatorBagInterface. RequestDataCollector - small fix renamed composer.phar to composer to be consistent with the Symfony docs [FrameworkBundle] bumped min version of Routing to 2.3 removed composer --dev option everywhere fixed a test [Console] Fixed output bug, if escaped string in a formatted string. “console help” ignores --raw option Fix form icon position in web profiler [Security] Remove ContextListener's onKernelResponse listener as it is used Revert "minor #12652 [HttpFoundation] [Hackday] #9942 test: Request::getContent() for null value (skler)" Revert "fixed assertion" fixed assertion [HttpFoundation] [Hackday] #9942 test: Request::getContent() for null value fixed URL Add reference to documentation in FormEvents phpdocs [YAML] Fix one-liners to work with multiple new lines Keep "pre" meaning for var_dump quick-and-dirty debug ... Conflicts: src/Symfony/Bridge/Twig/composer.json src/Symfony/Bundle/FrameworkBundle/composer.json src/Symfony/Component/Security/Http/Firewall/ContextListener.php src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php |
||
---|---|---|
.. | ||
Exception | ||
Node | ||
Parser | ||
Tests | ||
XPath | ||
.gitignore | ||
CHANGELOG.md | ||
composer.json | ||
CssSelector.php | ||
LICENSE | ||
phpunit.xml.dist | ||
README.md |
CssSelector Component
CssSelector converts CSS selectors to XPath expressions.
The component only goal is to convert CSS selectors to their XPath equivalents:
use Symfony\Component\CssSelector\CssSelector;
print CssSelector::toXPath('div.item > h4 > a');
HTML and XML are different
The CssSelector
component comes with an HTML
extension which is enabled by
default. If you need to use this component with XML
documents, you have to
disable this HTML
extension. That's because, HTML
tag & attribute names
are always lower-cased, but case-sensitive in XML
:
// disable `HTML` extension:
CssSelector::disableHtmlExtension();
// re-enable `HTML` extension:
CssSelector::enableHtmlExtension();
When the HTML
extension is enabled, tag names are lower-cased, attribute
names are lower-cased, the following extra pseudo-classes are supported:
checked
, link
, disabled
, enabled
, selected
, invalid
, hover
,
visited
, and the lang()
function is also added.
Resources
This component is a port of the Python cssselect library v0.7.1, which is distributed under the BSD license.
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/CssSelector/
$ composer install
$ phpunit