alyjee / from-xml-to-array
Conversion from xml to array
1.0
2018-06-05 07:56 UTC
Requires
- php: >=7.1
Requires (Dev)
- larapack/dd: ^1.1
- phpunit/phpunit: ^6.4
- spatie/array-to-xml: ^2.7
This package is not auto-updated.
Last update: 2025-03-20 18:59:26 UTC
README
A package inspired by vyuldashev/xml-to-array to convert an xml to array
Inspired by Vyuldashev's xml-to-array ❤️
Install
You can install this package via composer.
composer require alyjee/from-xml-to-array
Usage
use Alyjee\XmlToArray\XmlToArray; $xml = '<items><Facilities><Facility Code="*EC"><![CDATA[Earliest check-in at 14:00]]></Facility><Facility Code="*LF"><![CDATA[1 lift]]></Facility><Facility Code="*RS"><![CDATA[Room Service from 18:00 to 21:00]]></Facility></Facilities></items>'; $result = XmlToArray::convert($xml);
After running this piece of code $result
will contain:
Array ( [items] => Array ( [Facilities] => Array ( [Facility] => Array ( [0] => Array ( [_attributes] => Array ( [Code] => *EC ) [_cdata] => Earliest check-in at 14:00 ) [1] => Array ( [_attributes] => Array ( [Code] => *LF ) [_cdata] => 1 lift ) [2] => Array ( [_attributes] => Array ( [Code] => *RS ) [_cdata] => Room Service from 18:00 to 21:00 ) ) ) ) )