Skip to content

Commit

Permalink
feature #4039 [DomCrawler] Added node name getter (fejese)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

[DomCrawler] Added node name getter

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes (symfony/symfony#11426)
| Applies to    | all
| Fixed tickets |

Commits
-------

09c9af4 [DomCrawler] Added node name getter
  • Loading branch information
weaverryan committed Aug 16, 2014
2 parents aa70a98 + 09c9af4 commit e2f13a4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions components/dom_crawler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ Get all the child or parent nodes::
Accessing Node Values
~~~~~~~~~~~~~~~~~~~~~

.. versionadded:: 2.6
The :method:`Symfony\\Component\\DomCrawler\\Crawler::nodeName`
method was introduced in Symfony 2.6.

Access the node name (HTML tag name) of the first node of the current selection (eg. "p" or "div")::

// will return the node name (HTML tag name) of the first child element under <body>
$tag = $crawler->filterXPath('//body/*')->nodeName();

Access the value of the first node of the current selection::

$message = $crawler->filterXPath('//body/p')->text();
Expand Down

0 comments on commit e2f13a4

Please sign in to comment.