Daniel ab1334c0cf the whole shebang | 10 anni fa | |
---|---|---|
.. | ||
Field | 10 anni fa | |
Tests | 10 anni fa | |
.gitignore | 10 anni fa | |
CHANGELOG.md | 10 anni fa | |
Crawler.php | 10 anni fa | |
Form.php | 10 anni fa | |
FormFieldRegistry.php | 10 anni fa | |
LICENSE | 10 anni fa | |
Link.php | 10 anni fa | |
README.md | 10 anni fa | |
composer.json | 10 anni fa | |
phpunit.xml.dist | 10 anni fa |
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();
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/DomCrawler/
$ composer.phar install --dev
$ phpunit