PHPackages                             sbwerewolf/xml-navigator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. sbwerewolf/xml-navigator

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

sbwerewolf/xml-navigator
========================

XmlExtractKit for PHP: Stream large XML, extract only what matters, and get plain PHP arrays.

v10.10.19(2mo ago)514.1k↓29.5%Apache-2.0PHPPHP &gt;=8.4CI passing

Since Jan 1Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/SbWereWolf/xml-navigator)[ Packagist](https://packagist.org/packages/sbwerewolf/xml-navigator)[ Docs](https://github.com/SbWereWolf/xml-navigator)[ RSS](/packages/sbwerewolf-xml-navigator/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (25)Versions (54)Used By (0)

XmlExtractKit
=============

[](#xmlextractkit)

[![Packagist Version](https://camo.githubusercontent.com/eff4c2ef1ca6eac3e61802753d2ecb930660c56b763b9efad20a0ed025f3a0e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736277657265776f6c662f786d6c2d6e6176696761746f723f6c6162656c3d7061636b6167697374)](https://packagist.org/packages/sbwerewolf/xml-navigator)[![Packagist Downloads](https://camo.githubusercontent.com/672a978f630818e9038ab15200980e244fb9691ff82c2118d8c9921da9954494/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736277657265776f6c662f786d6c2d6e6176696761746f72)](https://packagist.org/packages/sbwerewolf/xml-navigator)[![PHP 8.4+](https://camo.githubusercontent.com/f7731561c72a9c36ec9858500edc3fefa15afc3c953bdbc7d2084925977f927b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342532422d373737424234)](https://www.php.net/)[![Static Analysis](https://github.com/SbWereWolf/xml-navigator/actions/workflows/static-analysis.yml/badge.svg)](https://github.com/SbWereWolf/xml-navigator/actions/workflows/static-analysis.yml)[![Test Coverage](https://camo.githubusercontent.com/0e40f25647de2445b0e3986da05b2cabb59aef22b0b9f99f76bd898f56116e0b/68747470733a2f2f636f6465636f762e696f2f6769746875622f536257657265576f6c662f786d6c2d6e6176696761746f722f67726170682f62616467652e7376673f746f6b656e3d5130425132434f465443)](https://codecov.io/github/SbWereWolf/xml-navigator)

**XmlExtractKit for PHP: Stream large XML, extract only what matters, and get plain PHP arrays.**

```
large XML → selected nodes → plain PHP arrays

```

Installation
------------

[](#installation)

```
composer require sbwerewolf/xml-navigator
```

For local test and coverage dependencies on a standard PHP 8.4 setup, see [`tests/ENVIRONMENT.md`](tests/ENVIRONMENT.md).

Why this package?
-----------------

[](#why-this-package)

XmlExtractKit is built for the boring XML jobs that show up in real systems:

- convert XML into native PHP arrays;
- stream huge XML files and extract only the elements you need;
- keep application code working with plain arrays instead of cursor-level `XMLReader` logic.

Use it for feeds, partner exports, imports, SOAP-ish payloads, marketplace catalogs, ETL pipelines, and other legacy XML integrations.

Core workflow
-------------

[](#core-workflow)

Open large XML with `XMLReader`, select matching nodes, receive plain PHP arrays.

```
use SbWereWolf\XmlNavigator\Parsing\FastXmlParser;

require_once __DIR__ . '/vendor/autoload.php';

$uri = tempnam(sys_get_temp_dir(), 'xml-extract-kit-');
file_put_contents(
    $uri,
     'offer',
  'a' =>
  array (
    'id' => '1001',
    'available' => 'true',
  ),
  's' =>
  array (
    0 =>
    array (
      'n' => 'name',
      'v' => 'Keyboard',
    ),
    1 =>
    array (
      'n' => 'price',
      'v' => '49.90',
      'a' =>
      array (
        'currency' => 'USD',
      ),
    ),
  ),
)
array (
  'n' => 'offer',
  'a' =>
  array (
    'id' => '1002',
    'available' => 'false',
  ),
  's' =>
  array (
    0 =>
    array (
      'n' => 'name',
      'v' => 'Mouse',
    ),
    1 =>
    array (
      'n' => 'price',
      'v' => '19.90',
      'a' =>
      array (
        'currency' => 'USD',
      ),
    ),
  ),
)
```

Index
-----

[](#index)

- [Turn XML into arrays with custom keys](#turn-xml-into-arrays-with-custom-keys)
- [Extract only the needed elements from large XML without loading the whole document](#extract-only-the-needed-elements-from-large-xml-without-loading-the-whole-document)
- [Convert XML to a traversable array and walk it with `XmlElement`](#convert-xml-to-a-traversable-array-and-walk-it-with-xmlelement)
- [Practical notes](#practical-notes)
- [Detailed documentation](#detailed-documentation)
- [Common use cases](#common-use-cases)
- [Pick your entry point](#pick-your-entry-point)
- [Contacts](#contacts)

Working examples
----------------

[](#working-examples)

### Turn XML into arrays with custom keys

[](#turn-xml-into-arrays-with-custom-keys)

Use `XmlConverter` when your project already has its own internal array contract and you want hierarchy output with your own key names.

```
use SbWereWolf\XmlNavigator\Conversion\XmlConverter;

require_once __DIR__ . '/vendor/autoload.php';

$converter = new XmlConverter(
    val: 'value',
    attr: 'attributes',
    name: 'name',
    seq: 'children',
);

$hierarchy = $converter->toHierarchyOfElements(
    '129.90'
);

var_export($hierarchy);
```

Output:

```
array (
  'name' => 'price',
  'value' => '129.90',
  'attributes' =>
  array (
    'currency' => 'USD',
  ),
)
```

### Extract only the needed elements from large XML without loading the whole document

[](#extract-only-the-needed-elements-from-large-xml-without-loading-the-whole-document)

Use `FastXmlParser` on top of `XMLReader` when the file is large and only some nodes matter.

```
use SbWereWolf\XmlNavigator\Parsing\FastXmlParser;

require_once __DIR__ . '/vendor/autoload.php';

$uri = tempnam(sys_get_temp_dir(), 'xml-extract-kit-');
file_put_contents(
    $uri,
     $tag->value(),
    $offer->elements('tag')
);

var_export($tagValues);
```

Output:

```
catalog
eu
yes

offer attributes:
id=1001
available=true

value of offer elements with name `tag`:
array (
  0 => 'office',
  1 => 'usb',
)

```

Practical notes
---------------

[](#practical-notes)

- attributes are always strings;
- repeated child tags become indexed arrays in readable output;
- empty elements become empty arrays in readable output and name-only nodes in normalized output;
- for one-shot conversion, provide either `$xmlText` or `$xmlUri`, but not both;
- if you already have an `XMLReader`, use the streaming API first instead of loading the entire document.

Detailed documentation
----------------------

[](#detailed-documentation)

The detailed method-by-method documentation stays available in dedicated files:

- [Examples by workflow and API](docs/examples.md)
- [Output formats: readable vs normalized](docs/output-formats.md)
- [Public API reference](docs/reference.md)

Standalone runnable snippets are also included in [`examples/`](examples).

Common use cases
----------------

[](#common-use-cases)

- supplier and marketplace feeds;
- partner imports and exports;
- ETL jobs that consume XML in batches;
- SOAP-ish or legacy integration payloads;
- queue payload preparation and JSON serialization;
- large catalogs where only selected nodes are relevant.

What it is not
--------------

[](#what-it-is-not)

XmlExtractKit is not trying to be:

- a full XML query language;
- an XML schema validator;
- an XML editor;
- an object mapper that hides XML structure behind a large abstraction layer.

The value proposition is much simpler:

> stream XML, extract only what matters, and keep working with plain arrays.

Pick your entry point
---------------------

[](#pick-your-entry-point)

NeedStart hereI need plain arrays from XML now`FastXmlToArray::prettyPrint()`I need a stable normalized structure for traversal`FastXmlToArray::convert()`I need to stream only matching elements from large XML`FastXmlParser::extractPrettyPrint()`I need streaming plus normalized output`FastXmlParser::extractHierarchy()`I need custom key names`XmlConverter` or `XmlParser`I need low-level composition around an existing cursor`PrettyPrintComposer` or `HierarchyComposer`Contacts
--------

[](#contacts)

```
Nicholas Volkhin
e-mail ulfnew@gmail.com
phone +7-902-272-65-35
Telegram @sbwerewolf

```

- [Telegram chat with me](https://t.me/SbWereWolf)
- [WhatsApp chat with me](https://wa.me/79022726535)

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance87

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~34 days

Recently: every ~3 days

Total

47

Last Release

74d ago

Major Versions

v5.2.7 → v6.2.72023-01-29

v6.2.8 → v7.2.82023-01-31

v6.2.9 → v8.2.112025-01-06

v8.3.17 → v9.3.172026-03-28

v8.3.18 → v10.3.172026-04-03

PHP version history (7 changes)v8.2.11PHP &gt;=8.4

v10.8.19PHP &gt;=8.0 &lt;8.3

v10.6.19PHP &gt;=7.3 &lt;7.4

v10.7.19PHP &gt;=7.4 &lt;8.0

v10.9.19PHP &gt;=8.3

v10.5.19PHP &gt;=7.0 &lt;7.3

v10.4.19PHP &gt;=5.6 &lt;7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/56415ea6aeceece7248ce372ec911905cab2cd1313ed2bb4ec8cfacdbaa7d08f?d=identicon)[SbWereWolf](/maintainers/SbWereWolf)

---

Top Contributors

[![SbWereWolf](https://avatars.githubusercontent.com/u/16444541?v=4)](https://github.com/SbWereWolf "SbWereWolf (106 commits)")

---

Tags

b2b-integrationdata-extractionetlfeed-parserintegrationmarketplace-feedphpphp-librarysoapstreaming-parsersupplier-feedxmlxml-parserxml-to-arrayxmlreaderxmlstreamingXMLReaderintegrationetlfeed parserxml-to-arrayxml-extraction

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sbwerewolf-xml-navigator/health.svg)

```
[![Health](https://phpackages.com/badges/sbwerewolf-xml-navigator/health.svg)](https://phpackages.com/packages/sbwerewolf-xml-navigator)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k269.7M320](/packages/masterminds-html5)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k141.9M929](/packages/jms-serializer)[sabre/xml

sabre/xml is an XML library that you may not hate.

55234.6M141](/packages/sabre-xml)[jms/metadata

Class/method/property metadata management in PHP

1.8k160.2M98](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k92.4M680](/packages/jms-serializer-bundle)[veewee/xml

XML without worries

1837.0M39](/packages/veewee-xml)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
