Skip to content
A35G edited this page Sep 10, 2026 · 2 revisions

json-to-xml — User Guide

Welcome to the wiki for a35g/json-to-xml, a PHP library for converting JSON to XML and back, with support for attributes, automatic CDATA, and mixed content.

What it does

The library provides two independent classes:

Class Direction Purpose
JsonToXmlConverter JSON → XML Generates an XML document from a JSON string
XmlToJsonConverter XML → JSON Generates a PHP array / JSON string from an XML document

Both share the same conventions for representing attributes, mixed text, and lists, so you can (almost) go back and forth between the two formats predictably.

Requirements

  • PHP 8.1 or higher
  • dom and json extensions (almost always available by default)

Installation

composer require a35g/json-to-xml

Page index

  1. Home (this page) — overview and installation
  2. Basic-Usage — first examples: JSON → XML and XML → JSON
  3. Conventions — attributes, mixed text, lists, automatic CDATA
  4. Round-Trip-and-Limitations — why XML → JSON is not a perfect inverse
  5. Security-and-Error-Handling — XXE protection, exceptions, tag sanitization
  6. Checklist-and-Further-Reading — quick recap and references

➡️ Next page: Basic-Usage

Clone this wiki locally