Convert XML to a PHP Array
Generate a PHP array literal from XML — perfect for config files and caches. Attributes, text and nested elements map to array keys.
Input
Output
About Convert XML to a PHP Array
Convert XML to a PHP Array produces a clean PHP array literal you can paste straight into PHP code. Elements become nested arrays, repeated elements become indexed arrays, attributes are stored under a configurable key and text under another.
Features
How to Use
Examples
The sample becomes $data = array('catalog' => array('product' => array(0 => array('@id' => 'p1', …))));
Benefits
Frequently Asked Questions
Is my XML sent to a server?
No. Everything runs locally in your browser. Your data is never uploaded, stored or logged.
Can I download the result?
Yes — use the Download button below the output area, or Print / Save PDF for a printable copy.
More XML Tools
View AllConvert a Data URI to XML
Decode a data: URL (base64 or percent-encoded) back into a readable, p...
Find XML Values
Find certain values in an XML file — text content and attribute values...
Edit and View XML
Free browser-based XML editor with a live collapsible tree view. Edit ...
Convert XML to SQL
Generate INSERT SQL queries from an XML file. Repeated records become ...
Convert XML to Properties
Flatten an XML file into a Java .properties file — nested elements bec...