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

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

maxnz/xml-builder
=================

Build XML easily and concisely

v1.0.1(4y ago)0225MITPHP

Since May 5Pushed 4y ago1 watchersCompare

[ Source](https://github.com/maxnz/php-xml-builder)[ Packagist](https://packagist.org/packages/maxnz/xml-builder)[ RSS](/packages/maxnz-xml-builder/feed)WikiDiscussions main Synced today

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

php-xml-builder
===============

[](#php-xml-builder)

Build XML in PHP easily and concisely.

Usage
-----

[](#usage)

### A Single XML element

[](#a-single-xml-element)

```
$xml = new XMLElement(
    qualifiedName: "elementName",
    value: "element value",
);

print($xml->buildXML());
```

```
element value
```

### Adding Attributes

[](#adding-attributes)

```
$xml = new XMLElement(
    qualifiedName: "elementName",
    value: "element value",
    attributes: [
        "attribute1" => "attribute 1 value",
        "attribute2" => "attribute 2 value",
    ],
);

print($xml->buildXML());
```

```
element value
```

### Child Elements

[](#child-elements)

```
$xml = new XMLElement(
    "elementName",
    "element value",
    [
        "attribute1" => "attribute 1 value",
        "attribute2" => "attribute 2 value",
    ],
    [
        new XMLElement(
            "child1",
            children: [
                new XMLElement(
                    "childOfChild",
                    "valueOfChild",
                )
            ]
        ),
        new XMLElement(
            "AnotherChild",
            "child2 Value",
        ),
    ],
);

print($xml->buildXML());
```

```
element valuevalueOfChildchild2 Value
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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 ~0 days

Total

2

Last Release

1520d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c7ab6a22c7ffe05f42b49d4728faf5b42b36e865c8107aa5f560d202048ff2b6?d=identicon)[maxnz](/maintainers/maxnz)

---

Top Contributors

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

---

Tags

xml

### Embed Badge

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

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k269.7M321](/packages/masterminds-html5)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k141.9M929](/packages/jms-serializer)[jms/metadata

Class/method/property metadata management in PHP

1.8k160.2M98](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k92.4M680](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

1.0k13.8M185](/packages/hassankhan-config)[sabre/xml

sabre/xml is an XML library that you may not hate.

55234.6M141](/packages/sabre-xml)

PHPackages © 2026

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