nkrumahthis / xml-to-array
将XML字符串解析为数组
v0.1.0-alpha
2024-02-23 08:28 UTC
Requires (Dev)
- phpunit/phpunit: ^9.6
This package is not auto-updated.
Last update: 2024-09-21 13:32:31 UTC
README
一个简单的PHP库,用于将XML字符串解析为关联数组。
安装
您可以通过Composer安装此包
composer require nkrumahthis/xml-to-array
用法
use Nkrumahthis\XMLToArray\XMLToArray; $xmlString = '<?xml version="1.0" encoding="UTF-8"?> <root> <name>John Doe</name> <age>30</age> <city>New York</city> </root>'; $array = XMLToArray::parse($xmlString); print_r($array);
这将输出
Array ( [root] => Array ( [name] => John Doe [age] => 30 [city] => New York ) )
测试
要运行PHPUnit测试,请使用
vendor/bin/phpunit .
贡献
欢迎贡献!请随意提交拉取请求或在GitHub上打开问题:nkrumahthis/xml-to-array。
许可证
此包使用MIT许可证授权。有关详细信息,请参阅LICENSE文件。