PHPackages                             evrenonur/xml2json - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. evrenonur/xml2json

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

evrenonur/xml2json
==================

XML to Json

v1.0(2y ago)4551↓86.7%MITPHP

Since Nov 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/evrenonur/xml2json)[ Packagist](https://packagist.org/packages/evrenonur/xml2json)[ RSS](/packages/evrenonur-xml2json/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)DependenciesVersions (2)Used By (0)

XML to JSON Converter
=====================

[](#xml-to-json-converter)

This PHP library allows you to convert XML data to JSON format using a simple and flexible approach. It provides a class, `XmlToJson`, with methods for converting XML to an associative array and then to JSON. ## Installation You can install the library via Composer. If you don't have Composer installed, you can [download it here](https://getcomposer.org/). `

```
 composer require evrenonur/xml2json

```

Usage
-----

[](#usage)

Include the Composer autoloader

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

```

**Use the `XmlToJson` class:**
------------------------------

[](#use-the-xmltojson-class)

```
    use  Onur\Xml2json\XmlToJson;

    // Load XML from a file
    $xmlNode = simplexml_load_file('path/to/your/file.xml');

    // Create an instance of XmlToJson
    $xmlToJson = new  XmlToJson();

    // Convert XML to JSON and echo the result
    echo  $xmlToJson->xmlToJson($xmlNode);
```

Replace `'path/to/your/file.xml'` with the path to your XML file.

Options
-------

[](#options)

The `xmlToArray` method of the `XmlToJson` class accepts an optional `$options` parameter to customize the conversion process. You can modify the default options by passing an associative array of options.

```
    $options = [
    'namespaceRecursive' => true,
    'removeNamespace' => false,
      // ... other options
     ];

  $xmlArray = $xmlToJson->xmlToArray($xmlNode, $options);
```

For a complete list of available options, refer to the [`XmlToJson` class source code](https://github.com/evrenonur/xml2json/blob/master/src/XmlToJson.php).

License
-------

[](#license)

This library is licensed under the MIT License

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

967d ago

### Community

Maintainers

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

---

Top Contributors

[![evrenonur](https://avatars.githubusercontent.com/u/49561437?v=4)](https://github.com/evrenonur "evrenonur (3 commits)")

### Embed Badge

![Health badge](/badges/evrenonur-xml2json/health.svg)

```
[![Health](https://phpackages.com/badges/evrenonur-xml2json/health.svg)](https://phpackages.com/packages/evrenonur-xml2json)
```

###  Alternatives

[charm/uuid

A very fast and dependency free library to generate UUIDs (GUIDs) version 1 or 4, sortable UUIDs that validates, or 64 bit unique identifiers according to Twitters' Snowflake, Sonyflake or Instaflake algorithms.

1227.8k](/packages/charm-uuid)

PHPackages © 2026

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