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 AllFilter an XML File
Filter XML keys and values that match a pattern — keep only matching e...
Convert XML to YAML
Free XML to YAML converter that maps elements, attributes and repeated...
Generate XML Art
Convert an image into a valid ASCII-art-like XML document — every row ...
Convert XML to PDF
Render XML as a clean, styled document and save it as a PDF in one cli...
Convert XML to Base64
Free XML to Base64 converter that UTF-8 encodes your document and prod...