定制 traineratwot/xmltodict 二次开发

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

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

traineratwot/xmltodict

最新稳定版本:1.1.1

Composer 安装命令:

composer require traineratwot/xmltodict

包简介

xml parser LIKE python xmltodict

README 文档

README

A complete analogue of XmlToDict for python, but written in PHP

Полный аналог XmlToDict для python, но написанный на PHP

install

composer require traineratwot/xmltodict

Usage

$array = XmlToDict::load(__DIR__ . '/test.xml');

$xml = file_get_contents(__DIR__ . '/test.xml')
$array = XmlToDict::parse($xml);

example

<?xml version="1.0" encoding="UTF-8"?>
<books>
	<book id="1">
		<title meta="test">Harry Potter and the Philosopher's Stone</title>
		<author>J.K. Rowling</author>
		<publisher>Bloomsbury</publisher>
		<year>1997</year>
	</book>
	<book id="2">
		<title meta="test2">The Lord of the Rings</title>
		<author>J.R.R. Tolkien</author>
		<publisher>George Allen &amp; Unwin</publisher>
		<year>1954</year>
	</book>
	<item>Text</item>
	<item2 desc="Lorem">Text</item2>

	<item3></item3>
</books>
{
    "books": {
        "book": [
            {
                "@id": "1",
                "title": {
                    "@meta": "test",
                    "#text": "Harry Potter and the Philosopher's Stone"
                },
                "author": "J.K. Rowling",
                "publisher": "Bloomsbury",
                "year": "1997"
            },
            {
                "@id": "2",
                "title": {
                    "@meta": "test2",
                    "#text": "The Lord of the Rings"
                },
                "author": "J.R.R. Tolkien",
                "publisher": "George Allen & Unwin",
                "year": "1954"
            }
        ],
        "item": "Text",
        "item2": {
            "@desc": "Lorem",
            "#text": "Text"
        },
        "item3": null
    }
}

supported

php 7.3+

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2023-05-20