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
2015-05-19 09:01:33 +01:00
..
Field [2.3] CS And DocBlock Fixes 2014-12-22 16:58:09 +01:00
Tests [DomCrawler] Throw an exception if a form field path is incomplete. 2015-05-19 09:01:33 +01: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 [2.3] require-dev PHPUnit bridge 2015-02-24 11:24:26 +01:00
Crawler.php CS: Convert double quotes to single quotes 2015-03-21 12:11:30 +01:00
Form.php Replace GET parameters when changed 2015-03-23 09:29:47 +01:00
FormFieldRegistry.php [DomCrawler] Throw an exception if a form field path is incomplete. 2015-05-19 09:01:33 +01:00
LICENSE Updated copyright to 2015 2015-01-01 13:56:52 +01:00
Link.php [2.3] Static Code Analysis for Components 2015-04-15 16:34:28 +02:00
phpunit.xml.dist [2.3] require-dev PHPUnit bridge 2015-02-24 11:24:26 +01:00
README.md renamed composer.phar to composer to be consistent with the Symfony docs 2015-02-08 08:41:14 +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 install
$ phpunit