11# XmlExtractKit
22
3- [ ![ Packagist Version] ( https://img.shields.io/packagist/v/sbwerewolf/xml-navigator?label=packagist )] ( https://packagist.org/packages/sbwerewolf/xml-navigator )
4- [ ![ Packagist Downloads] ( https://img.shields.io/packagist/dt/sbwerewolf/xml-navigator )] ( https://packagist.org/packages/sbwerewolf/xml-navigator )
5- [ ![ PHP 8.3+] ( https://img.shields.io/badge/PHP-8.3%2B-777BB4 )] ( https://www.php.net/ )
6- [ ![ Test Coverage] ( https://codecov.io/github/SbWereWolf/xml-navigator/graph/badge.svg?token=Q0BQ2COFTC )] ( https://codecov.io/github/SbWereWolf/xml-navigator )
3+ [ ![ PHP 7.0-7.2] ( https://img.shields.io/badge/PHP-7.0--7.2-777BB4 )] ( https://www.php.net/ )
4+ [ ![ Static Analysis] ( https://github.com/SbWereWolf/xml-navigator/actions/workflows/static-analysis.yml/badge.svg?branch=php7.0 )] ( https://github.com/SbWereWolf/xml-navigator/actions/workflows/static-analysis.yml?query=branch%3Aphp7.0 )
5+ [ ![ Test Coverage] ( https://codecov.io/github/SbWereWolf/xml-navigator/graph/badge.svg?token=Q0BQ2COFTC&branch=php7.0 )] ( https://codecov.io/github/SbWereWolf/xml-navigator/tree/php7.0 )
76
87
98** XmlExtractKit for PHP: Stream large XML, extract only what matters,
@@ -19,7 +18,7 @@ large XML → selected nodes → plain PHP arrays
1918composer require sbwerewolf/xml-navigator
2019```
2120
22- For local test and coverage dependencies on a standard PHP 8.3 setup ,
21+ For local test, coverage, and static-analysis dependencies for this branch ,
2322see [ ` tests/ENVIRONMENT.md ` ] ( tests/ENVIRONMENT.md ) .
2423
2524## Why this package?
6766);
6867
6968$reader = XMLReader::open($uri);
70- foreach (
71- FastXmlParser::extractHierarchy(
72- $reader,
73- static fn(XMLReader $cursor): bool =>
74- $cursor->nodeType === XMLReader::ELEMENT
75- && $cursor->name === 'offer'
76- ) as $offer
77- ) {
69+
70+ $offers = FastXmlParser::extractHierarchy(
71+ $reader,
72+ static function (XMLReader $cursor): bool {
73+ return $cursor->nodeType === XMLReader::ELEMENT
74+ && $cursor->name === 'offer';
75+ }
76+ );
77+
78+ foreach ($offers as $offer) {
7879 var_export($offer);
7980 echo PHP_EOL;
8081}
@@ -151,7 +152,7 @@ array (
151152
152153## Code test coverage
153154
154- ![ Codecov graph] ( https://codecov.io/github/SbWereWolf/xml-navigator/graphs/tree.svg?token=Q0BQ2COFTC )
155+ ![ Codecov graph] ( https://codecov.io/github/SbWereWolf/xml-navigator/graphs/tree.svg?token=Q0BQ2COFTC&branch=php7.0 )
155156
156157
157158## Working examples
@@ -167,10 +168,10 @@ use SbWereWolf\XmlNavigator\Conversion\XmlConverter;
167168require_once __DIR__ . '/vendor/autoload.php';
168169
169170$converter = new XmlConverter(
170- val: 'value',
171- attr: 'attributes',
172- name: 'name',
173- seq: 'children',
171+ 'value',
172+ 'attributes',
173+ 'name',
174+ 'children'
174175);
175176
176177$hierarchy = $converter->toHierarchyOfElements(
@@ -228,9 +229,10 @@ $reader = XMLReader::open($uri);
228229
229230$offers = FastXmlParser::extractHierarchy(
230231 $reader,
231- static fn(XMLReader $cursor):
232- bool => $cursor->nodeType === XMLReader::ELEMENT
233- && $cursor->name === 'offer'
232+ static function (XMLReader $cursor): bool {
233+ return $cursor->nodeType === XMLReader::ELEMENT
234+ && $cursor->name === 'offer';
235+ }
234236);
235237
236238$reader->close();
@@ -279,7 +281,7 @@ foreach ($offer->attributes() as $attribute) {
279281echo PHP_EOL;
280282echo 'offer elements with name `tag`:' . PHP_EOL;
281283$tagValues = array_map(
282- static fn (XmlElement $tag): string => $tag->value(),
284+ static function (XmlElement $tag): string { return $tag->value(); } ,
283285 $offer->elements('tag')
284286);
285287
0 commit comments