Permalink
Browse files

minor #3527 Changes to components domcrawler (ifdattic)

This PR was merged into the 2.3 branch.

Discussion
----------

Changes to components domcrawler

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.3
| Fixed tickets |

Commits
-------

0576f70 Fix typos, minimize horizontal scrolling
  • Loading branch information...
weaverryan committed Feb 4, 2014
2 parents 8973c81 + 0576f70 commit 9ba4fa7d35bfc02cab66e1f7f595a39c6ddf3e2a
Showing with 9 additions and 7 deletions.
  1. +9 −7 components/dom_crawler.rst
View
@@ -55,11 +55,11 @@ interacting with html links and forms as you traverse through the HTML tree.
.. note::
The DomCrawler will attempt to automatically fix your HTML to match the
official specification. For example, if you nest a `` <p>`` tag inside
another `` <p>`` tag, it will be moved to be a sibling of the parent tag.
official specification. For example, if you nest a ``<p>`` tag inside
another ``<p>`` tag, it will be moved to be a sibling of the parent tag.
This is expected and is part of the HTML5 spec. But if you're getting
unexpected behavior, this could be a cause. And while the DomCrawler
isn't meant to dump content, you can see the "fixed" version if your HTML
isn't meant to dump content, you can see the "fixed" version of your HTML
by :ref:`dumping it <component-dom-crawler-dumping>`.
Node Filtering
@@ -83,10 +83,12 @@ Anonymous function can be used to filter with more complex criteria::
use Symfony\Component\DomCrawler\Crawler;
// ...
$crawler = $crawler->filter('body > p')->reduce(function (Crawler $node, $i) {
// filter even nodes
return ($i % 2) == 0;
});
$crawler = $crawler
->filter('body > p')
->reduce(function (Crawler $node, $i) {
// filter even nodes
return ($i % 2) == 0;
});
To remove a node the anonymous function must return false.

0 comments on commit 9ba4fa7

Please sign in to comment.