ericmorand / xml-to-array
Simple XML-to-array converter
Installs: 295
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/ericmorand/xml-to-array
Requires
- ext-simplexml: *
Requires (Dev)
- phpunit/phpunit: ^6.4
This package is auto-updated.
Last update: 2025-12-05 23:07:58 UTC
README
This package provides a very simple converter to convert an XML string to an array. No attributes support, no complex logic, just a plain and simple converter that just works.
Installation
composer require ericmorand/xml-to-array
Usage
<?php use EricMorand\XMLToArray; $converter = new XMLToArray\Converter(); $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <foo> <prop0/> <prop1>foo</prop1> <prop2><![CDATA[foo]]></prop2> <prop3> <prop0/> <prop1>foo</prop1> <prop2><![CDATA[foo]]></prop2> </prop3> </foo>"; $array = $converter->convertXML($xml);
By running this code, $array would contain:
[
'prop0' => null,
'prop1' => 'foo',
'prop2' => 'foo',
'prop3' => [
'prop0' => null,
'prop1' => 'foo',
'prop2' => 'foo'
]
]