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/DomCrawler
Christian Flothmann d26040f356 [DomCrawler] fix the axes handling in a bc way
The previous fix in #11548 for handling XPath axes was not backward
compatible. In previous Symfony versions the Crawler handled nodes
by holding a "fake root node". This must be taken into account when
evaluating (relativizing) XPath expressions.
2014-08-09 11:40:56 +02:00
..
Field [DomCrawler] Fixed filterXPath() chaining 2014-05-21 15:37:53 +02:00
Tests [DomCrawler] fix the axes handling in a bc way 2014-08-09 11:40:56 +02:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md [DomCrawler] finished the previous merge feature addition 2013-04-22 07:03:23 +02:00
composer.json removed versions in composer.json files 2013-05-13 16:36:40 +02:00
Crawler.php [DomCrawler] fix the axes handling in a bc way 2014-08-09 11:40:56 +02:00
Form.php issue #10808 crawler test 2014-06-06 07:27:49 +02:00
FormFieldRegistry.php [DomCrawler] Fixed the coding standards to use strict comparisons 2014-05-17 15:36:43 +02:00
LICENSE update year on licenses 2014-01-07 08:19:25 -05:00
Link.php [DomCrawler] Fix docblocks and formatting. 2014-07-03 23:56:58 +01:00
phpunit.xml.dist removed defaults from PHPUnit configuration 2014-07-07 12:13:42 +02:00
README.md updated the composer install command to reflect changes in Composer 2013-09-18 09:27:26 +02:00

DomCrawler Component

DomCrawler eases DOM navigation for HTML and XML documents.

If you are familiar with jQuery, DomCrawler is a PHP equivalent:

use Symfony\Component\DomCrawler\Crawler;

$crawler = new Crawler();
$crawler->addContent('<html><body><p>Hello World!</p></body></html>');

print $crawler->filterXPath('descendant-or-self::body/p')->text();

If you are also using the CssSelector component, you can use CSS Selectors instead of XPath expressions:

use Symfony\Component\DomCrawler\Crawler;

$crawler = new Crawler();
$crawler->addContent('<html><body><p>Hello World!</p></body></html>');

print $crawler->filter('body > p')->text();

Resources

You can run the unit tests with the following command:

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