Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions components/dom_crawler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ traverse easily::
print $domElement->nodeName;
}

Specialized :class:`Symfony\\Component\\DomCrawler\\Link` and
Specialized :class:`Symfony\\Component\\DomCrawler\\Link`,
:class:`Symfony\\Component\\DomCrawler\\Image` and
:class:`Symfony\\Component\\DomCrawler\\Form` classes are useful for
interacting with html links and forms as you traverse through the HTML tree.
interacting with html links, images and forms as you traverse through the HTML
tree.

.. note::

Expand Down Expand Up @@ -303,7 +305,7 @@ Links
~~~~~

To find a link by name (or a clickable image by its ``alt`` attribute), use
the ``selectLink`` method on an existing crawler. This returns a Crawler
the ``selectLink`` method on an existing crawler. This returns a ``Crawler``
instance with just the selected link(s). Calling ``link()`` gives you a special
:class:`Symfony\\Component\\DomCrawler\\Link` object::

Expand All @@ -327,6 +329,23 @@ methods to get more information about the selected link itself::
page suffixed with ``#foo``. The return from ``getUri()`` is always a full
URI that you can act on.

Images
~~~~~~

To find an image by its ``alt`` attribute, use the ``selectImage`` method on an
existing crawler. This returns a ``Crawler`` instance with just the selected
image(s). Calling ``image()`` gives you a special
:class:`Symfony\\Component\\DomCrawler\\Image` object::

$imagesCrawler = $crawler->selectImage('Kitten');
$image = $imagesCrawler->image();

// or do this all at once
$image = $crawler->selectImage('Kitten')->image();

The :class:`Symfony\\Component\\DomCrawler\\Image` object has the same
``getUri()`` method as :class:`Symfony\\Component\\DomCrawler\\Link`.

Forms
~~~~~

Expand Down