PHPackages                             jtrumbull/xml-parser - 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. jtrumbull/xml-parser

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

jtrumbull/xml-parser
====================

PHP Class that parses XML objects

v1.0.2(10y ago)1846.6k—1.8%15[4 issues](https://github.com/jtrumbull/xml-parser/issues)[1 PRs](https://github.com/jtrumbull/xml-parser/pulls)2MITPHPPHP &gt;=5.3.0

Since Aug 4Pushed 3y ago2 watchersCompare

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

READMEChangelog (3)DependenciesVersions (4)Used By (2)

XMLParser
=========

[](#xmlparser)

I needed a quick way of outputting XML from an associative array on a few projects -this was the end result. I created this repository for later reference and fellow devs. At the time, It served it's purpose, however I am not actively developing this project -see the [Contributing](#contributing) section.

Table of contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [Community](#community)
- [Copyright and license](#copyright-and-license)

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

[](#installation)

- composer require jtrumbull/xml-parser

\##Usage

```
header('Content-type: text/xml');

use XMLParser\XMLParser;

$data = array(
  'attr:status'=>'success',
  'Person'=>array(
    'attr:id'=>987654321,
    'First Name'=>'John',
    'Last Name'=>'Smith'
  ),
  'Address'=>array(
    'attr:'=>array(
      'geo-coded'=>TRUE,
      'lat'=>'0.0000',
      'lon'=>'-0.0000'
    ),
    'Street'=>'123 Main Street',
    'City'=>'Somewhere',
    'State'=>'DE',
    'Zip'=>'12345'
  ),
  'other'=>array(
    'key'=>'value',
    array('value1','value2','value3')
  )
);

$xml = XMLParser::encode( $data , 'response' );
echo $xml->asXML();
```

Will output:

```

    John
    Smith

    123 Main Street
    Somewhere
    DE
    12345

    value

      value1
      value2
      value3

```

Documentation
-------------

[](#documentation)

### XMLParser\\XMLParser::encode()

[](#xmlparserxmlparserencode)

**Syntax:**

```
SimpleXMLElement XMLParser::encode( mixed $data [, string $root] )
```

**Returns:** SimpleXMLElement

### XMLParser\\XMLParser::decode()

[](#xmlparserxmlparserdecode)

**Syntax:**

```
json XMLParser::decode( mixed $string )
```

**Returns:** json

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

[](#contributing)

Check out the [issue](https://github.com/jtrumbull/XMLParser/issues) tracker, if your issue or feature request has not addressed open a new issue. All pull requests are welcome.

Community
---------

[](#community)

Copyright and license
---------------------

[](#copyright-and-license)

XML parser is distributed under the MIT License -see [LICENSE.md](https://github.com/jtrumbull/XMLParser/blob/master/LICENSE.md)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 51.9% 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 ~92 days

Total

3

Last Release

3756d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/95b8bcbeda75d9628411b64bdb997345968cd262c02040f3d19adbcaf688b763?d=identicon)[jtrumbull](/maintainers/jtrumbull)

---

Top Contributors

[![jtrumbull](https://avatars.githubusercontent.com/u/2381008?v=4)](https://github.com/jtrumbull "jtrumbull (14 commits)")[![nimasdj](https://avatars.githubusercontent.com/u/6756021?v=4)](https://github.com/nimasdj "nimasdj (12 commits)")[![mikk150](https://avatars.githubusercontent.com/u/4953629?v=4)](https://github.com/mikk150 "mikk150 (1 commits)")

### Embed Badge

![Health badge](/badges/jtrumbull-xml-parser/health.svg)

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

###  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)
