2b296028ac
* 2.8: (21 commits) [Security][bugfix] "Remember me" cookie cleared on logout with custom "secure"/"httponly" config options [1] [ci] Use current PHP_BINARY when running ./phpunit Fixed typos [UPGRADE-3.0] fix bullet indentation Throw exception if tempnam returns false in ProcessPipes [DomCrawler] Deprecated using /_root/ in XPath expressions Pass missing request template variables Simplify AbstractVoter [Form] add missing deprecation triggers Throw exception if tempnam returns false Fix PropertyAccessor modifying array in object when array key does not exist [DependencyInjection] Add autowiring capabilities Fixing typo in variable name Add a few additional tests for the Crawler [Form] remove obsolete deprecation comments Updated the style of the event commands [Debug] Deprecate providing $fileLinkFormat as second argument [Form] minor CS fix Updated PHPDoc of the AbstractVoter class [Security] InMemoryUserProvider now concerns whether user's password is changed when refreshing ... |
||
---|---|---|
.. | ||
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