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
2012-02-27 09:59:20 +01:00
..
Field [DoctrineBridge] fixed some CS 2011-12-13 10:22:12 +01:00
composer.json Removed version field 2012-02-27 09:59:20 +01:00
Crawler.php [DomCrawler] added a way to get parsing errors for Crawler::addHtmlContent() and Crawler::addXmlContent() via libxml functions 2011-09-28 10:00:18 +02:00
Form.php fixed CS, phpdoc, removed unused use statements 2012-01-28 18:02:36 +01:00
LICENSE Updated LICENSE files copyright 2012-02-22 10:10:37 +01:00
Link.php optimized string starts with checks 2012-01-11 11:33:56 -08:00
README.md tweaked the README files 2011-12-18 14:22:28 +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

Unit tests:

https://github.com/symfony/symfony/tree/master/tests/Symfony/Tests/Component/DomCrawler