74c4974998
* 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 |
||
---|---|---|
.. | ||
Field | ||
Tests | ||
.gitignore | ||
CHANGELOG.md | ||
composer.json | ||
Crawler.php | ||
Form.php | ||
FormFieldRegistry.php | ||
LICENSE | ||
Link.php | ||
phpunit.xml.dist | ||
README.md |
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