alyjee / from-xml-to-array
XML到数组的转换
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: 2024-09-19 16:33:22 UTC
README
受vyuldashev/xml-to-array启发的包,用于将XML转换为数组
受Vyuldashev的 xml-to-array 启发 ❤️
安装
您可以通过composer安装此包。
composer require alyjee/from-xml-to-array
用法
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);
运行此段代码后,$result
将包含
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 ) ) ) ) )