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
Nicolas Grekas cb9f8342c4 Merge branch '2.7'
* 2.7:
  [2.6] Test lowest versions of dependencies
  Test lowest versions of dependencies
  Fix placeholder date format
  Test components using their lowest possible deps
2014-12-16 21:28:59 +01:00
..
Field Merge branch '2.3' into 2.5 2014-12-02 21:15:53 +01:00
Tests Merge branch '2.5' into 2.6 2014-12-02 21:19:20 +01:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md Changed the default value of checkbox and radio to match the HTML spec 2014-05-17 22:15:05 +02:00
composer.json Merge branch '2.7' 2014-12-16 21:28:59 +01:00
Crawler.php Merge branch '2.5' into 2.6 2014-12-02 21:19:20 +01:00
Form.php Merge branch '2.3' into 2.5 2014-12-02 21:15:53 +01:00
FormFieldRegistry.php Docblock fixes 2014-11-30 13:33:44 +00:00
LICENSE update year on licenses 2014-01-07 08:19:25 -05:00
Link.php [DomCrawler] Added support for link tags in the Link class 2014-11-16 18:39:20 +01:00
phpunit.xml.dist Adjust error_reporting to allow deprecation messages for 3.0 2014-11-29 13:40:43 +01:00
README.md [Doc] Use Markdown syntax highlighting 2014-10-01 07:38:33 +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