# spatie/array-to-xml

A simple class to convert an array to xml

Repository: https://github.com/spatie/array-to-xml
Canonical: https://ross.abutalabs.com/products/array-to-xml
Homepage: https://spatie.be/open-source
Language: PHP
License: MIT
License Family: permissive
Topics: xml, configuration, array, api
Last push: 2026-06-26T09:43:49+00:00

## Health v2 (maintenance only)
Score: 81/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 89, release rhythm 61, longevity 100
- inputs: {"age_days": 4187, "days_push": 68, "days_rel": 261, "gap_med": 15.5, "n_releases_24m": 5}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1199, forks 216 (observed 2026-08-28T04:03:57.798087+00:00)

## What it is
A small PHP library by Spatie that converts PHP arrays into XML strings using a single static method. It supports custom root elements, attribute handling, and key-name sanitization.

## Use cases
- convert php array to xml string
- generate xml from nested array in php
- serialize array as xml with attributes
- set custom root element for xml output
- produce xml api responses from php arrays

## When to choose
- you need a lightweight, dependency-free way to turn PHP arrays into XML
- you want attribute and value support via simple array conventions
- you're working in a PHP or Laravel project and need quick XML serialization

## When to avoid
- you need XML parsing or array-from-XML conversion (this only writes XML)
- you need advanced XML features like namespaces, CDATA control, or streaming for huge documents

## Facets
- artifact type: library
- maturity: stable
- function: serialization
- domain: files, developer-tools, apis
- platform: php
- tags: xml, array-conversion, php-package, spatie

## Member repositories
- spatie/array-to-xml (main) score 81

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:03:57.798087+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T06:21:06.892878+00:00, confidence not recorded.
  - readme: https://github.com/spatie/array-to-xml (fetched 2026-08-28T04:03:57.798087+00:00, sha fd7ff133319c)
  - homepage: https://spatie.be/open-source (fetched 2026-08-29T12:28:16.048953+00:00, sha 6ed5abf69535)
  - site_page: https://spatie.be/docs (fetched 2026-08-29T12:28:16.051707+00:00, sha 08e024d86d95)
  - site_page: https://spatie.be/about-us (fetched 2026-08-29T12:28:16.053523+00:00, sha d3cb88e4b34c)
- Data as of 2026-08-30T08:39:29.467469+00:00.
