PHPackages                             halilim/xml-iterator - 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. halilim/xml-iterator

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

halilim/xml-iterator
====================

XML Reader to simplexml/array iterator with low memory usage and an acceptable level of ease of use.

v2.0.0(3mo ago)21373.6k—0.2%8[1 PRs](https://github.com/halilim/xml-iterator/pulls)1MITPHPPHP &gt;=8.2CI passing

Since Nov 30Pushed 3mo ago2 watchersCompare

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

READMEChangelog (1)Dependencies (2)Versions (6)Used By (1)

xml-iterator
============

[](#xml-iterator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4868894af229e84928c9ace6bd9f685212a320ec2c9f351d2738600ad49648ed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68616c696c696d2f786d6c2d6974657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/halilim/xml-iterator)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://github.com/halilim/xml-iterator/actions/workflows/ci.yml/badge.svg)](https://github.com/halilim/xml-iterator/actions/workflows/ci.yml)[![Coverage Status](https://camo.githubusercontent.com/404cbfc3621708a85b05a012a7226e8d922f1bc0c44b562b7463c7d93dc78374/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f68616c696c696d2f786d6c2d6974657261746f722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/halilim/xml-iterator/code-structure)[![Quality Score](https://camo.githubusercontent.com/4b7f5f3b6a00b82d4bf87bfdfff5292115cf97769707382c5ecc8eb45602d849/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f68616c696c696d2f786d6c2d6974657261746f722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/halilim/xml-iterator)[![Total Downloads](https://camo.githubusercontent.com/6faf6367b308ca6456d3b980ea655557a61351f61b32bfd72d2ab18801944622/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68616c696c696d2f786d6c2d6974657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/halilim/xml-iterator)

XML Reader to array/object iterator with low memory usage (basically a Space–time tradeoff) and an acceptable level of ease of use. Mostly useful for importing sequential data from external API's.

Installation (Composer)
-----------------------

[](#installation-composer)

```
$ composer require "halilim/xml-iterator"
```

Usage
-----

[](#usage)

```
use XmlIterator\XmlIterator;
$it = new XmlIterator("http://api.example.com/products.xml", "product");

foreach ($it as $k => $v) {
    // Do something with each row ($v), save it to db, echo it, etc. E.g.:
    // echo $k . " => " . var_export($v, true) . "\n\n";
}
```

Note: When working with remote files it's advised to copy the file to a temporary local location first. Otherwise if the import takes a long time, "extra content at the end of the document" kind of errors may occur (or at least this was what happened to me).

Example input:

```

        Lorem
        ACME

            http://www.example.com/image1.jpg
            http://www.example.com/image2.jpg

        Ipsum
        Etc LLC

            http://www.example.com/image3.jpg
            http://www.example.com/image4.jpg

```

Example output:

```
0 => array (
  'title' => 'Lorem',
  'brand' => 'ACME',
  'images' =>
  array (
    'image' =>
    array (
      0 => 'http://www.example.com/image1.jpg',
      1 => 'http://www.example.com/image2.jpg',
    ),
  ),
)

1 => array (
  'title' => 'Ipsum',
  'brand' => 'Etc LLC',
  'images' =>
  array (
    'image' =>
    array (
      0 => 'http://www.example.com/image3.jpg',
      1 => 'http://www.example.com/image4.jpg',
    ),
  ),
)
```

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

List of Contributors
--------------------

[](#list-of-contributors)

We thank all [our contributors](https://github.com/halilim/xml-iterator/graphs/contributors) for their contributions.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

60

—

FairBetter than 99% of packages

Maintenance81

Actively maintained with recent releases

Popularity45

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 93.3% 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 ~2044 days

Total

3

Last Release

100d ago

Major Versions

1.0.1 → v2.0.02026-02-08

PHP version history (2 changes)1.0.0PHP &gt;=5.3

v2.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/1e103158521397802c6f822921290c333f3a5b772a6956657010126beff47ed4?d=identicon)[halil](/maintainers/halil)

![](https://www.gravatar.com/avatar/488c93e63cb2701a038be750682c86b97ef3ddf63f6ad0397471e38dc77e7c4a?d=identicon)[rfussien](/maintainers/rfussien)

---

Top Contributors

[![halilim](https://avatars.githubusercontent.com/u/226712?v=4)](https://github.com/halilim "halilim (28 commits)")[![eberhm](https://avatars.githubusercontent.com/u/1044082?v=4)](https://github.com/eberhm "eberhm (2 commits)")

---

Tags

xmliteratorXMLReaderSimpleXML

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/halilim-xml-iterator/health.svg)

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

###  Alternatives

[dkrnl/simplexmlreader

Wrapper XMLReader class, for simple SAX-reading(and simple XPath-queries) of huge(testing over 1G file) xml.

112951.5k](/packages/dkrnl-simplexmlreader)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[jms/serializer

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

2.3k135.8M851](/packages/jms-serializer)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[sabre/xml

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

52832.2M131](/packages/sabre-xml)[jms/serializer-bundle

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

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

PHPackages © 2026

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