alextartan / xml2array
轻量级的xml与array转换工具。
2.0.2
2020-11-09 09:38 UTC
Requires
- php: >=7.4
- ext-dom: *
- ext-libxml: *
Requires (Dev)
- infection/infection: ^0.13.0 || ^0.15.0 || ^0.16.0 || ^0.20.0
- php-coveralls/php-coveralls: ^2.1
- phpstan/phpstan: 0.11.20
- phpstan/phpstan-phpunit: ^0.11
- phpstan/phpstan-strict-rules: ^0.11
- phpunit/phpunit: ^8.2.0 || ^9.0.0
- squizlabs/php_codesniffer: ^3.4
- dev-master
- 2.0.2
- 2.0.1
- 2.0.0
- 1.3.1
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.2
- 1.0.1
- 0.5.0
- 0.2.0
- 0.1.0
- 0.0.1
- dev-dependabot/composer/phpunit/phpunit-9.5.28
- dev-dependabot/composer/php-coveralls/php-coveralls-2.5.3
- dev-dependabot/composer/guzzlehttp/guzzle-7.4.5
- dev-dependabot/composer/squizlabs/php_codesniffer-3.7.1
- dev-dependabot/composer/guzzlehttp/psr7-1.8.5
- dev-dependabot/composer/infection/infection-0.21.5
This package is auto-updated.
Last update: 2024-09-21 20:07:53 UTC
README
Array与XML转换包
轻量级XML解析器
当前构建状态
安装
最简单的方式是使用composer
composer require alextartan/xml2array
备注
最新版本需要PHP
>= 7.2以及dom
扩展(ext-dom
)
对于PHP
<= 7.2,请使用版本1.0.2
使用方法
ArrayToXml
将XML(无论是DOMDocument还是字符串)转换为数组
// default value:
$config = [
'version' => '1.0',
'encoding' => 'UTF-8',
'attributesKey' => '@attributes',
'cdataKey' => '@cdata',
'valueKey' => '@value',
'useNamespaces' => false,
'forceOneElementArray => false,
];
$xtoa = new XmlToArray($config);
$array = $xtoa->buildArrayFromString($xmlString);
$array = $xtoa->buildArrayFromDomDocument($xmlDom);
XmlToArray
将数组转换为DOMDocument
// default value:
$config = [
'version' => '1.0',
'encoding' => 'UTF-8',
'attributesKey' => '@attributes',
'cdataKey' => '@cdata',
'valueKey' => '@value',
'formatOutput' => false,
];
$atox = new ArrayToXml($config);
$xml = $atox->buildXml($array);
问题和pull请求。
发现的问题应在本仓库的问题跟踪器中报告,问题将在可能时修复。将接受pull请求,但请遵循PSR2编码标准。所有构建必须通过才能合并PR。