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 85e08278ca Merge branch '2.4'
* 2.4:
  Fixed the XPath filtering to have the same behavior than Symfony 2.4
  [DomCrawler] Fixed filterXPath() chaining
  [DomCrawler] Added more tests for the XPath filtering
  [PropertyAccess] Fixed inverted logic
  [HttpKernel] fixed file uploads in functional tests when no file was selected
  [PropertyAccess] fixed CS
  Fixed test cases failing when the Intl extension is not installed
  Fixed the Travis build to avoid exiting too early
  [PropertyAccess] Fixed getValue() when accessing non-existing indices of ArrayAccess implementations
  [PropertyAccess] Refactored PropertyAccessorCollectionTest
  [PropertyAccess] Refactored PropertyAccessorTest
2014-05-21 18:04:07 +02:00
..
Field Merge branch '2.4' 2014-05-21 18:04:07 +02:00
Tests Merge branch '2.4' 2014-05-21 18:04:07 +02: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 updated version to 2.5 2013-11-24 21:17:07 +01:00
Crawler.php Merge branch '2.4' 2014-05-21 18:04:07 +02:00
Form.php Merge branch '2.4' 2014-05-21 18:04:07 +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 Merge branch '2.4' 2014-05-17 22:48:44 +02: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