6acf3e74ae
* 2.5: [Doc] Use Markdown syntax highlighting [Finder] tweaked docs [Finder] Add info about possibilities offered by SplFileInfo fixed CS [Security][Http][Authentication] Make a test pass on HHVM fix components tests [Intl] FIxed failing test [Intl] Generated the data for ICU version 54-rc [EventDispatcher] fix doc bloc on EventDispatcherInterface [Validator] Update validators.zh_CN.xlf, fix translation error bumped Symfony version to 2.5.6 updated VERSION for 2.5.5 updated CHANGELOG for 2.5.5 bumped Symfony version to 2.3.21 updated VERSION for 2.3.20 update CONTRIBUTORS for 2.3.20 updated CHANGELOG for 2.3.20 [Intl] Integrated ICU data into Intl component Conflicts: src/Symfony/Component/Debug/README.md src/Symfony/Component/DependencyInjection/README.md src/Symfony/Component/HttpKernel/Kernel.php src/Symfony/Component/OptionsResolver/README.md |
||
---|---|---|
.. | ||
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.phar install
$ phpunit