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 c15175ab00 Merge branch '2.4'
* 2.4:
  fix some cs
  use restore_error_handler instead of set_error_handler($previous)
  fix #9321 Crawler::addHtmlContent add gbk encoding support
  [Console] fixed column width when using the Table helper with some decoration in cells
  [Security] Fixed problem with losing ROLE_PREVIOUS_ADMIN role.
  Fix for cache-key conflict when having a \Traversable as choices
  [Security] removed obsolete comment
2013-12-29 21:34:05 +01:00
..
Field [DomCrawler] Allowed internal validation of ChoiceFormField to be disabled 2013-10-01 10:36:54 +02:00
Tests Merge branch '2.3' into 2.4 2013-12-29 21:33:52 +01:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md fixed CS 2013-12-17 14:01:50 +01:00
composer.json updated version to 2.5 2013-11-24 21:17:07 +01:00
Crawler.php Merge branch '2.3' into 2.4 2013-12-29 21:33:52 +01:00
Form.php Merge branch '2.3' into 2.4 2013-12-29 15:43:38 +01:00
FormFieldRegistry.php [DomCrawler] Fixed a fatal error when setting a value in a malformed field name. 2013-06-08 13:27:47 +02:00
LICENSE updated license year 2013-01-04 17:59:43 +01:00
Link.php fixed acronyms 2013-12-28 09:33:14 +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 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