azurre/php-array-xml-converter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

azurre/php-array-xml-converter

最新稳定版本:0.5.1

Composer 安装命令:

composer require azurre/php-array-xml-converter

包简介

Array2XML conversion library credit to lalit.org

README 文档

README

Array2Xml conversion library credit to lalit.org

Usage

//create XML
$xml = Array2Xml::createXML('root_node_name', $php_array);
echo $xml->saveXML();

//create Array
$array = Xml2Array::createArray($xml);
print_r($array);

Array2Xml

@xml example:

// Build the array that should be transformed into a XML object.
$array = [
    'title' => 'A title',
    'body' => [
        '@xml' => '<html><body><p>The content for the news item</p></body></html>',
    ],
];

// Use the Array2XML object to transform it.
$xml = Array2Xml::createXML('news', $array);
echo $xml->saveXML();

This will result in the following.

<?xml version="1.0" encoding="UTF-8"?>
<news>
  <title>A title</title>
  <body>
    <html>
      <body>
        <p>The content for the news item</p>
      </body>
    </html>
  </body>
</news>

Reference

More complete references can be found here http://www.lalit.org/lab/convert-xml-to-array-in-php-xml2array/ http://www.lalit.org/lab/convert-php-array-to-xml-with-attributes/

Changelog

0.5.1

  • Fix fata error when the array passed is empty fixed by pull request #6

0.5.0

  • add second parameter to XML2Array::createArray for DOMDocument::load, e.g: LIBXML_NOCDATA
  • change method visibility from private to protected for overloading
  • Merge pull request #5 to add child xml
  • Merge pull request #4 to change method visibility and add second parameter for load.

0.1.0

  • Initial Release

统计信息

  • 总下载量: 183
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 26
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2019-01-23