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

ActiveLibrary

thenorthmemory/xml
==================

A wrapper of the XML parser and builder

1.1.1(3y ago)9605.8k↑91.8%20Apache-2.0PHPPHP &gt;=7.1.2CI passing

Since Sep 25Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/TheNorthMemory/xml)[ Packagist](https://packagist.org/packages/thenorthmemory/xml)[ Docs](https://github.com/TheNorthMemory/xml)[ RSS](/packages/thenorthmemory-xml/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (20)

A wrapper of the XML parser and builder
=======================================

[](#a-wrapper-of-the-xml-parser-and-builder)

Split from the wechatpay-php project for general usages.

[![GitHub actions](https://github.com/TheNorthMemory/xml/workflows/CI/badge.svg)](https://github.com/TheNorthMemory/xml/actions)[![Packagist Stars](https://camo.githubusercontent.com/0434e8e7496c6b84623400e8fb73443ed86496626f963668dd2390716c3539fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f7468656e6f7274686d656d6f72792f786d6c)](https://packagist.org/packages/thenorthmemory/xml)[![Packagist Downloads](https://camo.githubusercontent.com/8c1637a72bf457a8b5a901ea7b317609fac8ea6f9f825672a0e9f2d9f162ac19/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f7468656e6f7274686d656d6f72792f786d6c)](https://packagist.org/packages/thenorthmemory/xml)[![Packagist Version](https://camo.githubusercontent.com/7e23980b73ef86f14deb2b7756165558e09e448b4aad9e7fd83dcc2ce0f61c52/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7468656e6f7274686d656d6f72792f786d6c)](https://packagist.org/packages/thenorthmemory/xml)[![Packagist PHP Version Support](https://camo.githubusercontent.com/ce52bd5803a48f027737847bfed9ae88068e39c162bfbc96ce9af25e538f5f99/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7468656e6f7274686d656d6f72792f786d6c)](https://packagist.org/packages/thenorthmemory/xml)[![Packagist License](https://camo.githubusercontent.com/2addd081f0d59c447a647d1703c9853c6c2dd2a4ba9a424529792847bffd9832/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7468656e6f7274686d656d6f72792f786d6c)](https://packagist.org/packages/thenorthmemory/xml)

Install
-------

[](#install)

```
composer require thenorthmemory/xml
```

Usage
-----

[](#usage)

```
use TheNorthMemory\Xml\Transformer;
$array = Transformer::toArray('world');
// print_r($array);
// Array
// (
//     [hello] => world
// )
$xml = Transformer::toXml($array);
// print_r($xml);
// world
$xml =  t146d70eb241c44c63b6efc1cc93ccfc5d
//                     [1] => t12a74d11687d444deba8a6cc52051ac27
//                 )

//         )

// )
$xml1 = Transformer::toXml($array, true, true, 'Request');
// print_r($xml1);
//
//
//
//    t146d70eb241c44c63b6efc1cc93ccfc5d
//    t12a74d11687d444deba8a6cc52051ac27
//
//
//
$array['Operation']['WatermarkTemplateId'] = Transformer::wrap($array['Operation']['WatermarkTemplateId'], true, 'WatermarkTemplateId');
$xml2 = Transformer::toXml($array, true, true, 'Request');
// print_r($xml2);
//
//
//  t146d70eb241c44c63b6efc1cc93ccfc5d
//  t12a74d11687d444deba8a6cc52051ac27
//
//
```

API
---

[](#api)

**`Transformer::toArray(string $xml = '')`**

Parse the XML `string` to `array`.

**`Transformer::sanitize(string $xml = '')`**

Sanitize the XML `string` in the [XML1.0 20081126 Character Range](https://www.w3.org/TR/2008/REC-xml-20081126/#charsets).

**`Transformer::toXml(array $data, bool $headless = true, bool $indent = false, string $root = 'xml', string $item = 'item'): string`**

Build the data `array` to XML `string`.

**`Transformer::wrap(array $data, bool $wrapped = false, string $label = 'item'): LabeledArrayIterator`**

Wrap the `array` data with a `label` and `wrapped` flag.

License
-------

[](#license)

[Apache-2.0 License](LICENSE)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity44

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

Every ~56 days

Total

3

Last Release

1219d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0944cd912c2e052b3940ec4a6a8732ea973a8c4a477df75a849b5ac5f0831b97?d=identicon)[TheNorthMemory](/maintainers/TheNorthMemory)

---

Top Contributors

[![TheNorthMemory](https://avatars.githubusercontent.com/u/1631685?v=4)](https://github.com/TheNorthMemory "TheNorthMemory (18 commits)")

---

Tags

xml-parserxml-builder

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[wechatpay/wechatpay

\[A\]Sync Chainable WeChatPay v2&amp;v3's OpenAPI SDK for PHP

589355.9k28](/packages/wechatpay-wechatpay)[illuminated/helper-functions

Laravel-specific and pure PHP Helper Functions.

107586.6k7](/packages/illuminated-helper-functions)[inspirum/xml

Simple XML writer and memory efficient XML reader with powerful xml-to-array cast

1012.5k2](/packages/inspirum-xml)

PHPackages © 2026

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