782ba96f76
* 2.5: updated VERSION for 2.4.7 updated CHANGELOG for 2.4.7 bumped Symfony version to 2.3.18 updated VERSION for 2.3.17 update CONTRIBUTORS for 2.3.17 updated CHANGELOG for 2.3.17 added XSD to PHPUnit configuration fix the return types add missing docblock for ProcessBuilder::addEnvironmentVariables() bug #11319 [HttpKernel] Ensure the storage exists before purging it in ProfilerTest [Translation] Added unescaping of ids in PoFileLoader updated italian translation for validation messages [DomCrawler] Fix docblocks and formatting. [DomCrawler] Remove the query string and the anchor of the uri of a link Simplified the Travis test command Remove Expression Language services when the component is unavailable Added SK translations [Console] Make sure formatter is the same |
||
---|---|---|
.. | ||
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