This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/CssSelector
Fabien Potencier 05815adb22 Merge branch '2.5'
* 2.5:
  added missing use statements
  added missing use statement
  added missing use statement
  fixed CS
  [Process] fixed some volatile tests
  [HttpKernel] fixed a volatile test
  [HttpFoundation] fixed some volatile tests
  [Tests] PHPUnit Optimizations
  Use getPathname() instead of string casting to get BinaryFileReponse file path

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
	src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php
	src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php
	src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php
	src/Symfony/Component/Process/Process.php
	src/Symfony/Component/Stopwatch/Stopwatch.php
	src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php
	src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php
	src/Symfony/Component/Yaml/Parser.php
	src/Symfony/Component/Yaml/Tests/InlineTest.php
2014-09-22 13:59:59 +02:00
..
Exception [CssSelector] fully rewritted component 2013-03-23 19:04:09 +01:00
Node Rename Specificity->compare() to compareTo() 2014-07-18 09:44:18 +02:00
Parser Merge branch '2.3' into 2.4 2014-09-22 10:51:05 +02:00
Tests Rename Specificity->compare() to compareTo() 2014-07-18 09:44:18 +02:00
XPath Refactored the CssSelector to remove the circular object graph 2014-06-27 09:58:31 +02:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md [CssSelector] added CHANGELOG 2012-04-26 22:11:05 +02:00
composer.json updated version to 2.6 2014-05-23 16:36:49 +02:00
CssSelector.php [CssSelector] fixed BC break 2013-03-23 20:31:06 +01:00
LICENSE update year on licenses 2014-01-07 08:19:25 -05:00
phpunit.xml.dist removed defaults from PHPUnit configuration 2014-07-07 12:13:42 +02:00
README.md [CssSelector] Fix URL to SimonSapin/cssselect repo 2014-08-27 10:24:06 +02:00

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 lxml library, which is copyright Infrae and distributed under the BSD license.

Current code is a port of https://github.com/SimonSapin/cssselect/releases/tag/v0.7.1

You can run the unit tests with the following command:

$ cd path/to/Symfony/Component/CssSelector/
$ composer.phar install
$ phpunit