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 74c4974998 Merge branch '2.8' into 3.0
* 2.8:
  [VarDumper] Fix tests on PHP 7
  [DomCrawler] Clarify the value returned by getPhpFiles()
  [DependencyInjection] Fix #16461 Let Container::set() replace existing aliases
  avoid (string) catchable fatal error for instances of __PHP_Incomplete_Class
  remove unnecessary retrieval and setting of data
  Update validators.fr.xlf
  avoid (string) catchable fatal error for __PHP_Incomplete_Class instances
  sendContent return as parent.
  [DomCrawler] Remove the overridden getHash() method to prevent problems when cloning the crawler
  [FrameworkBundle] Fix a typo
  Added more exceptions to singularify method
  Add width attribute on SVG
  [FrameworkBundle] Support autowiring for TranslationInterface
  [WebProfiler] Fixed styles for search block and menu profiler for IE Edge

Conflicts:
	src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php
	src/Symfony/Component/DomCrawler/Crawler.php
2016-02-13 10:23:44 +01:00
..
Field Merge branch '2.3' into 2.7 2015-09-29 14:06:14 +02:00
Tests Merge branch '2.8' into 3.0 2015-12-28 14:14:56 +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.8' 2015-10-30 16:35:59 -07:00
Crawler.php [DomCrawler] Remove the overridden getHash() method to prevent problems when cloning the crawler 2016-02-10 13:25:51 +00:00
Form.php Merge branch '2.3' into 2.7 2016-02-13 10:21:13 +01:00
FormFieldRegistry.php [DomCrawler] Throw an exception if a form field path is incomplete. 2015-05-19 09:01:33 +01:00
LICENSE Update copyright year 2016-01-01 23:53:47 -03:00
Link.php Merge branch '2.3' into 2.7 2015-09-29 14:06:14 +02:00
phpunit.xml.dist [ci] SymfonyTestsListener is now auto-registered 2015-10-11 11:37:49 +02: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