Skip to content

Commit e2f13a4

Browse files
committed
feature #4039 [DomCrawler] Added node name getter (fejese)
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
2 parents aa70a98 + 09c9af4 commit e2f13a4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

components/dom_crawler.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,15 @@ Get all the child or parent nodes::
193193
Accessing Node Values
194194
~~~~~~~~~~~~~~~~~~~~~
195195

196+
.. versionadded:: 2.6
197+
The :method:`Symfony\\Component\\DomCrawler\\Crawler::nodeName`
198+
method was introduced in Symfony 2.6.
199+
200+
Access the node name (HTML tag name) of the first node of the current selection (eg. "p" or "div")::
201+
202+
// will return the node name (HTML tag name) of the first child element under <body>
203+
$tag = $crawler->filterXPath('//body/*')->nodeName();
204+
196205
Access the value of the first node of the current selection::
197206

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

0 commit comments

Comments
 (0)