PHPackages                             sergeynezbritskiy/xml-io - 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. sergeynezbritskiy/xml-io

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

sergeynezbritskiy/xml-io
========================

Library for parsing and generating XML

v5.0.2(5y ago)26.1k↓40%1[1 PRs](https://github.com/sergeynezbritskiy/xml-io/pulls)2MITPHPPHP ^7.0|^8.0CI failing

Since Mar 5Pushed 3y ago1 watchersCompare

[ Source](https://github.com/sergeynezbritskiy/xml-io)[ Packagist](https://packagist.org/packages/sergeynezbritskiy/xml-io)[ RSS](/packages/sergeynezbritskiy-xml-io/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (1)Versions (10)Used By (2)

xml-io
======

[](#xml-io)

Library for Parsing xml into php array using easy mapping. It allows you to parse simple data like strings and numbers, arrays or a list of items and complex data like objects. Also any combination of these data types is allowed.

[![Build Status](https://camo.githubusercontent.com/8eae577499041b78b4dc9b5a2eb1ef27e601f25707976300171e31857971c4cd/68747470733a2f2f7472617669732d63692e6f72672f7365726765796e657a62726974736b69792f786d6c2d696f2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/sergeynezbritskiy/xml-io)[![Latest Stable Version](https://camo.githubusercontent.com/b5f4df9e57a005fb2eb8f5512ff602d66bb7d602ce1f3e7c451ba887669f727a/68747470733a2f2f706f7365722e707567782e6f72672f7365726765796e657a62726974736b69792f786d6c2d696f2f762f737461626c65)](https://packagist.org/packages/sergeynezbritskiy/xml-io)[![Total Downloads](https://camo.githubusercontent.com/5fe7b668f8118400bd33ec2d7045dd3b8150b09bb5c4239b275eb9a3209377d6/68747470733a2f2f706f7365722e707567782e6f72672f7365726765796e657a62726974736b69792f786d6c2d696f2f646f776e6c6f616473)](https://packagist.org/packages/sergeynezbritskiy/xml-io)[![Latest Unstable Version](https://camo.githubusercontent.com/66a998734116c0d3fb334f8eb8a4066af91d3cebb2c58f3b2e7a6c326554741d/68747470733a2f2f706f7365722e707567782e6f72672f7365726765796e657a62726974736b69792f786d6c2d696f2f762f756e737461626c65)](https://packagist.org/packages/sergeynezbritskiy/xml-io)[![License](https://camo.githubusercontent.com/688c4aa3483eee31e874f85689af7948d23ab32348d1ebf245a251cd2aad78f2/68747470733a2f2f706f7365722e707567782e6f72672f7365726765796e657a62726974736b69792f786d6c2d696f2f6c6963656e7365)](https://packagist.org/packages/sergeynezbritskiy/xml-io)

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

[](#installation)

The easiest way to install module is using Composer

```
composer require sergeynezbritskiy/xml-io:^5.0.0

```

Simple usage
------------

[](#simple-usage)

The most useful test cases can be seen in tests

Here is the most generic example. Lets pretend we have such xml as below

```

    Sergey
    1988-20-12

        2000-12-12

        buono
        brutto
        cattivo

            Kharkiv
            Ukraine

            London
            Great Britain

```

Here is an example of how to convert such xml into array:

```
$xmlString = ' xml string from above ';
$xmlReader = new \SergeyNezbritskiy\XmlIo\XmlReader();
$user = $xmlReader->stringToArray($xmlString, [
    //array element with key `id` will be created from attribute `id`
    'id' => '@id',
    //array element with key `name` will be created from tag `name`
    'name' => 'name',
    'born' => 'born',
    'born_format' => 'born.@format',
    'passport' => [
        'id' => '@id',
        'date' => 'date',
    ],
    //create simple list of items
    'keywords as keywords.keyword' => '{list}',
    //create element `addresses` which will be an array of associative arrays
    'addresses as addresses.address[]' => [
        'city' => 'city',
        'country' => 'country',
    ]
]);

the result will be smth like that:
$user = [
    'id' => '1',
    'name' => 'Sergey',
    'born' => '1988-20-12',
    'born_format' => 'ISO',
    'passport' => [
        'id' => 'MN123456',
        'date' => '2000-12-12',
    ],
    'keywords' => [
        'buono',
        'brutto',
        'cattivo'
    ],
    'addresses' => [
        [
            'city' => 'Kharkiv',
            'country' => 'Ukraine'
        ],[
            'city' => 'London',
            'country' => 'Great Britain'
        ],
    ]
];

and back, convert array to xml
$xmlWriter = new \SergeyNezbritskiy\XmlIo\XmlWriter();
$xml = $xmlWriter->toXmlString($user,
'user' => [
    'attributes' => ['id'],
    'children' => [
        'name',
        'born',
        'passport' => [
            'attributes' => ['id'],
            'children' => 'date',
        ],
        'keywords' => [
            'children' => [
                'keyword[]' => [
                    'dataProvider' => 'keywords',
                    'text' => '{self}',
                ],
            ],
        ],
        'addresses' => [
            'children' => [
                'address[]' => [
                    'dataProvider' => 'addresses',
                    'children' => ['city', 'country'],
                ],
            ],
        ],
    ],
]);
```

Inspiration
-----------

[](#inspiration)

Author was inspired for creating of this library by

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity74

Established project with proven stability

 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 ~132 days

Recently: every ~263 days

Total

9

Last Release

1940d ago

Major Versions

v1.0.0 → v2.0.02018-03-06

v2.0.1 → v3.0.02018-03-08

v3.0.1 → v4.0.02018-03-10

v4.0.0 → v5.0.02018-03-12

PHP version history (2 changes)v3.0.0PHP ^7.0

v5.0.1PHP ^7.0|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c119fcbb8c23d87df8de13605e93188a14663680d0455aa5f64fc89b93a932c?d=identicon)[sergeynezbritskiy](/maintainers/sergeynezbritskiy)

---

Top Contributors

[![sergeynezbritskiy](https://avatars.githubusercontent.com/u/8030069?v=4)](https://github.com/sergeynezbritskiy "sergeynezbritskiy (62 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sergeynezbritskiy-xml-io/health.svg)

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

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

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

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