extphp/xml-to-json
Composer 安装命令:
composer require extphp/xml-to-json
包简介
An XML to JSON converter that will properly preserve attributes.
关键字:
README 文档
README
An XML to JSON converter that will properly preserve attributes.
Installation
composer require extphp/xml-to-json
Usage
A generic usage, usefull when the SimpleXMLElement instance already exists.
use ExtPHP\XmlToJson\XmlToJsonConverter; $string = '<node attr1="value1" attr2="value2"><child>child value</child></node>'; $xml = simplexml_load_string($string); $converter = new XmlToJsonConverter($xml); $converter->toArray(); // convert xml to array $converter->toJson(); // convert xml to json
A quick approach when you need to convert a XML string to array or json.
use ExtPHP\XmlToJson\JsonableXML; $xml = new JsonableXML('<node attr1="value1" attr2="value2"><child>child value</child></node>'); json_encode($xml); // convert xml to json // These methods are also available directly on the xml object. $xml->toArray(); // convert xml to array $xml->toJson(); // convert xml to json
统计信息
- 总下载量: 23.77k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-20