alextartan/xml2array
最新稳定版本:2.0.2
Composer 安装命令:
composer require alextartan/xml2array
包简介
Lightweight xml<->array conversion.
关键字:
README 文档
README
Array <-> XML conversion package
Lightweight XML parser
Current build status
Install
The easiest way is to use composer:
composer require alextartan/xml2array
Notes:
Latest release requires PHP >= 7.2 and the dom extension (ext-dom)
For PHP <= 7.2, use version 1.0.2
Usage
ArrayToXml
Convert an XML (either DOMDocument or string) to an array
// 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
Convert an array to a 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);
Issues and pull requests.
Any issues found should be reported in this repository issue tracker, issues will be fixed when possible. Pull requests will be accepted, but please adhere to the PSR2 coding standard. All builds must pass in order to merge the PR.
统计信息
- 总下载量: 40.9k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2018-08-28