PHPackages                             krosscode/xml-to-object - 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. krosscode/xml-to-object

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

krosscode/xml-to-object
=======================

Converts XML into an object

1.0.0(6y ago)24GPL-3.0-or-laterPHPPHP ^7.0

Since Nov 15Pushed 6y ago1 watchersCompare

[ Source](https://github.com/krosscode/xml-to-object)[ Packagist](https://packagist.org/packages/krosscode/xml-to-object)[ RSS](/packages/krosscode-xml-to-object/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (0)

XML to object
=============

[](#xml-to-object)

This library simply converts XML into an object.

Getting started
---------------

[](#getting-started)

XML to object is very easy to use. **Example:**

```
// Using composer here, but you can also directly include XmlToObject.php
require_once __DIR__ . '/vendor/autoload.php';

// Import the function
use function KrossCode\XmlToObject\xmlToObject;

// First we need to get the contents of our XML file
$xmlContents = file_get_contents('path/to/xml/file.xml');
if (!$xmlContents) return false; // File couldn't be read

// Now we try to convert the XML to an object
$xmlObject = xmlToObject($xmlContents);
if (!$xmlObject) return false; // XML couldn't be converted to an object

print_r($xmlObject); // Success!
```

Example
-------

[](#example)

What does the object look like, compared to the XML?

### XML

[](#xml)

```

	Johnny's Green Goods

			Cucumber
			63
			1.99

			Carrot
			24
			1.79

```

### Object (represented in JSON)

[](#object-represented-in-json)

```
{
    "Name": "Johnny's Green Goods",
    "GroceryCollection": {
        "Grocery": [
            {
                "@attributes": {
                    "id": "13"
                },
                "Name": "Cucumber",
                "Amount": "63",
                "Price": "1.99"
            },
            {
                "@attributes": {
                    "id": "17"
                },
                "Name": "Carrot",
                "Amount": "24",
                "Price": "1.79"
            }
        ]
    }
}
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

2422d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22466906?v=4)[Sean Krossing](/maintainers/krosscode)[@krosscode](https://github.com/krosscode)

---

Top Contributors

[![krosscode](https://avatars.githubusercontent.com/u/22466906?v=4)](https://github.com/krosscode "krosscode (1 commits)")

---

Tags

composer-packageconverterobjectphpphp-libraryphp7xml

### Embed Badge

![Health badge](/badges/krosscode-xml-to-object/health.svg)

```
[![Health](https://phpackages.com/badges/krosscode-xml-to-object/health.svg)](https://phpackages.com/packages/krosscode-xml-to-object)
```

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19139.2M47](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9843.5k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

45153.1k6](/packages/jstewmc-rtf)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.2k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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