Skip to content

Commit 063aaa5

Browse files
committed
Update readme
1 parent 96dffbc commit 063aaa5

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

README.md

+8-14
Original file line numberDiff line numberDiff line change
@@ -154,29 +154,23 @@ var_dump($price);
154154
*/
155155
```
156156

157-
Splitting data to XML fragments (with valid namespaces)
157+
Splitting data to XML fragments by xpath (with valid namespaces)
158158

159159
```php
160-
$items = function(): iterable {
161-
/** @var \Inspirum\XML\Reader\ReaderFactory $factory */
162-
$reader = $factory->create('/output/feeds/google.xml');
163-
164-
foreach ($reader->iterateNode('/rss/channel/item', true) as $item) {
165-
yield $item->toString();
166-
}
167-
}
160+
/** @var \Inspirum\XML\Reader\ReaderFactory $factory */
161+
$reader = $factory->create('/output/feeds/google.xml');
168162

169-
foreach ($items as $item) {
170-
$xml = \simplexml_load_string($item);
171-
$id = $xml->xpath('/item/g:id')[0] ?? null
172-
// ...
163+
foreach ($reader->iterateNode('/rss/channel/item', true) as $item) {
164+
$data = $item->toString();
165+
$id = ($item->xpath('/item/g:id')[0] ?? null)?->getTextContent()
166+
// ...
173167
}
174168
```
175169

176170

177171
## System requirements
178172

179-
* [PHP 8.1+](http://php.net/releases/8_1_0.php)
173+
* [PHP 8.2+](http://php.net/releases/8_2_0.php)
180174
* [ext-dom](http://php.net/dom)
181175
* [ext-json](http://php.net/json)
182176
* [ext-xmlreader](http://php.net/xmlreader)

0 commit comments

Comments
 (0)