定制 deepeloper/lib-xml 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

deepeloper/lib-xml

最新稳定版本:3.1.0

Composer 安装命令:

composer require deepeloper/lib-xml

包简介

XML library allowing to parse XML as array converting node values/attributes types using XSD

README 文档

README

Packagist version PHP from Packagist GitHub license GitHub issues Packagist CI codecov

Donation

Compatibility

PHP 5.4

Installation

composer require deepeloper/lib-xml

Usage

use deepeloper\Lib\XML\Converter;

require_once "/path/to/vendor/autoload.php";

$converter = new Converter();

// @see https://www.php.net/manual/en/function.xml-parse-into-struct.php#66487
// Little bit modified.
$xml = $converter->xmlToArray(
    file_get_contents("/path/to/xml")
);

// lib-xml<3.0.0, PHP<8.1:
$xml = $converter->parse(
    file_get_contents("/path/to/xml"),
    file_get_contents("/path/to/xsd"),
    [
        // Optional, used to move attributes from '/attributes' key to the element. 
        Converter::COLLAPSE_ATTRIBUTES => true,
        // Optional, used to move children from '/children' key to the element as arrays named as child name. 
        Converter::COLLAPSE_CHILDREN => true,
        // Optional, used to convert arrays from previous option as 'name' => "value". 
        Converter::COLLAPSE_ARRAYS => [
            // Optional, used to exclude collapsing for list of the elements. 
            'exclusions' => [
                "node/subnode/...",
                // ...,
            ],
        ],
    ]
);

// lib-xml>=3.0.0, PHP>=8.1:
$xml = $converter->parse(
    file_get_contents("/path/to/xml"),
    [
        file_get_contents("/path/to/xsd1"),
        file_get_contents("/path/to/xsd2"),
        // ...    
    ],
    [
        Converter::COLLAPSE_ATTRIBUTES => true,
        Converter::COLLAPSE_CHILDREN => true,
        Converter::COLLAPSE_ARRAYS => [
            'exclusions' => [
                "node/subnode/...",
                // ...,
            ],
        ],
    ]
);

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固