fawno/simple-xml-extended
最新稳定版本:1.1.2
Composer 安装命令:
composer require fawno/simple-xml-extended
包简介
SimpleXMLElement Extended class
README 文档
README
SimpleXMLElement Extended class SimpleXMLExtended add a new method for create CData nodes. Also added a new method for output e nice format XML.
Requirements
- libxml PHP extension (enabled by default).
- SimpleXML PHP extension (enabled by default).
- DOM PHP extension (enabled by default).
Installation
You can install this plugin into your application using composer:
composer require fawno/simple-xml-extended
or, clone/download this repo, and include src/SimpleXMLExtended.php in your project.
Usage
use Fawno\SimpleXMLExtended\SimpleXMLExtended; // Get a SimpleXMLExtended object from a DOM node $xml = simplexml_import_dom($dom, SimpleXMLExtended::class); // Interprets an XML file into an SimpleXMLExtended object $xml = simplexml_load_file($xml_file, SimpleXMLExtended::class); // Interprets a string of XML into an SimpleXMLExtended object $xml = simplexml_load_string($xml_string, SimpleXMLExtended::class); // Creates a new SimpleXMLExtended object $xml = new SimpleXMLExtended($xml_string); // Adds a child element to the XML node as cdata $xml->addChildCData('node_cdata', 'data as cdata'); // Return a well-formed and nice formated XML string based on SimpleXMLExtended element $xml->formatXML()
Example
require 'src/SimpleXMLExtended.php'; use Fawno\SimpleXMLExtended\SimpleXMLExtended; $root = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><root/>'); $root->addChildCData('node_cdata', 'data as cdata'); print_r($root->asXML()); /* Output: <?xml version="1.0" encoding="UTF-8"?> <root><node_cdata><![CDATA[data as cdata]]></node_cdata></root> */ print_r($root->formatXML()); /* Output: <?xml version="1.0" encoding="UTF-8"?> <root> <node_cdata><![CDATA[data as cdata]]></node_cdata> </root> */
统计信息
- 总下载量: 11.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-12-15