Skip to content

Commit 3f27c94

Browse files
committed
[#961] Clarifying what the DomDocument component is intended to do / not do - thanks to @jakzal
1 parent 0b0164f commit 3f27c94

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

components/dom_crawler.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ The DomCrawler Component
77

88
The DomCrawler Component eases DOM navigation for HTML and XML documents.
99

10+
.. note::
11+
12+
While possible, the DomCrawler is not designed for manipulation of the
13+
DOM or re-dumping HTML/XML.
14+
1015
Installation
1116
------------
1217

@@ -172,6 +177,22 @@ and :phpclass:`DOMNode` objects:
172177
$crawler->addNode($node);
173178
$crawler->add($document);
174179
180+
.. note::
181+
182+
These methods on the ``Crawler`` are intended to initially populate your
183+
``Crawler`` and aren't intended to be used to further manipulate a DOM
184+
(though this is possible). However, since the ``Crawler`` is a set of
185+
:phpclass:`DOMElement` objects, you can use any method or property available
186+
on :phpclass:`DOMElement`, :phpclass:`DOMNode` or :phpclass:`DOMDocument`.
187+
For example, you could get the HTML of a ``Crawler`` with something like
188+
this::
189+
190+
$html = '';
191+
192+
foreach ($crawler as $domElement) {
193+
$html.= $domElement->ownerDocument->saveHTML();
194+
}
195+
175196
Form and Link support
176197
~~~~~~~~~~~~~~~~~~~~~
177198

0 commit comments

Comments
 (0)