PHPackages                             muhammetsafak/toxml - 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. muhammetsafak/toxml

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

muhammetsafak/toxml
===================

XML to Array and Array to XML

1.0(3y ago)02MITPHPPHP &gt;=5.6

Since Jun 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/muhammetsafak/toXML)[ Packagist](https://packagist.org/packages/muhammetsafak/toxml)[ RSS](/packages/muhammetsafak-toxml/feed)WikiDiscussions main Synced 1w ago

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

toXML
=====

[](#toxml)

This library provides the simplest and most straightforward way to switch between XML and Array.

Requirements
------------

[](#requirements)

- PHP 5.6 or higger
- PHP DOM Extension

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

[](#installation)

```
composer require muhammetsafak/toxml

```

Configuration
-------------

[](#configuration)

The following array is the associative configuration array declaring identifiable configurations. It can be defined while creating an object, or it can be defined later using setter methods.

```
array(
    'encode'            => 'UTF-8', // String
    'version'           => '1.0', // String ("1.0" or "1.1")
    'attributesKey'     => '@attibutes', // String
    'cdataKey'          => '@cdata', // String
    'valueKey'          => '@value', // String
    'useNamespaces'     => false, // Boolean
    'rootNodeName'      => 'root', // String
);
```

Usage
-----

[](#usage)

### Array to XML

[](#array-to-xml)

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

$data = array();

$xml = new \MuhammetSafak\ToXML\XML();

header('Content-Type: application/xml; charset=utf-8');
echo $xml->withArray($data)
        ->toXML();
```

### XML to Array

[](#xml-to-array)

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

$source = file_get_contents('example.xml');

$xml = new \MuhammetSafak\ToXML\XML();
$data = $xml->withXML($source)
            ->toArray();
```

Credits
-------

[](#credits)

- [Muhammet ŞAFAK](https://www.muhammetsafak.com.tr) &lt;&gt;

License
-------

[](#license)

Copyright © 2022 [MIT Licence](./LICENSE)

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

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

1437d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b6b34f3ac8938d8ee52ba3bd260680855dc5715c7b2929d9380de30d15a67dd?d=identicon)[muhammetsafak](/maintainers/muhammetsafak)

---

Top Contributors

[![muhammetsafak](https://avatars.githubusercontent.com/u/104234499?v=4)](https://github.com/muhammetsafak "muhammetsafak (2 commits)")

### Embed Badge

![Health badge](/badges/muhammetsafak-toxml/health.svg)

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

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[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)[michelf/php-markdown

PHP Markdown

3.5k52.4M345](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

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

PHPackages © 2026

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