File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -97,10 +97,12 @@ To remove a node the anonymous function must return false.
97
97
98
98
Both :method: `Symfony\\ Component\\ DomCrawler\\ Crawler::filterXPath ` and
99
99
:method: `Symfony\\ Component\\ DomCrawler\\ Crawler::filter ` methods work with
100
- XML namespaces, which are automatically registered.
100
+ XML namespaces, which can be either automatically discovered or registered
101
+ explicitly.
101
102
102
103
.. versionadded :: 2.4
103
- Auto discovery of namespaces was introduced in Symfony 2.4.
104
+ Auto discovery and explicit registration of namespaces was introduced
105
+ in Symfony 2.4.
104
106
105
107
Consider an XML below:
106
108
@@ -136,13 +138,18 @@ and :method:`Symfony\\Component\\DomCrawler\\Crawler::filter`::
136
138
changed with the
137
139
:method: `Symfony\\ Component\\ DomCrawler\\ Crawler::setDefaultNamespacePrefix `.
138
140
141
+ Namespaces can be explicitly registered with the
142
+ :method: `Symfony\\ Component\\ DomCrawler\\ Crawler::registerNamespace `::
143
+
144
+ $crawler->registerNamespace('m', 'http://search.yahoo.com/mrss/');
145
+ $crawler = $crawler->filterXPath('//m:group//yt:aspectRatio');
146
+
139
147
.. caution ::
140
148
141
149
To query an XML with a CSS selector, the HTML extension needs to be disabled with
142
150
:method: `Symfony\\ Component\\ CssSelector\\ CssSelector::disableHtmlExtension `
143
151
to avoid converting the selector to lowercase.
144
152
145
-
146
153
Node Traversing
147
154
~~~~~~~~~~~~~~~
148
155
You can’t perform that action at this time.
0 commit comments