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
Fabien Potencier f989c846fe Merge branch '2.2' into 2.3
* 2.2:
  [CssSelector] Fix :nth-last-child() translation
  Fix Crawler::children() to not trigger a notice for childless node

Conflicts:
	src/Symfony/Component/CssSelector/Node/FunctionNode.php
	src/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php
2013-05-19 21:00:48 +02:00
..
Field merge branch '2.1' into 2.2 2013-04-01 10:05:23 +02:00
Tests Merge branch '2.2' into 2.3 2013-05-19 21:00:48 +02:00
.gitignore made usage of Composer autoloader for subtree-split unit tests 2012-11-09 14:10:06 +01: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 Merge branch '2.2' into 2.3 2013-05-19 21:00:48 +02:00
Form.php [DomCrawler] added support for HTML5 'form' attribute 2013-04-01 14:38:28 +02:00
FormFieldRegistry.php [DomCrawler] fixed a bad merge 2012-10-09 14:26:19 +02:00
LICENSE updated license year 2013-01-04 17:59:43 +01:00
Link.php Merge branch '2.2' 2013-03-20 15:03:03 +01:00
phpunit.xml.dist made usage of Composer autoloader for subtree-split unit tests 2012-11-09 14:10:06 +01:00
README.md made usage of Composer autoloader for subtree-split unit tests 2012-11-09 14:10:06 +01: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 --dev
$ phpunit