tcgunel/xml-aligner

该软件包已被弃用且不再维护。未建议替代软件包。

通过给定数组的结构转换小/大XML文件,以最小的内存消耗。

v1.1.0 2021-12-13 20:58 UTC

This package is auto-updated.

Last update: 2023-10-19 07:24:20 UTC


README

License Buy us a tree PHP Composer

XML对齐器

通过给定数组的结构转换小/大XML文件,以最小的内存消耗

仅处理标签及其内容。属性将被忽略。

使用XMLWriter、XMLReader、fopen进行内存效率。SimpleXML用于解析XML标签的小部分。

需求

PHP 软件包
^7.3-^8.0 v1.0.0

安装

  1. 使用composer下载软件包
composer require TCGunel/xml-aligner

示例用法

1:n发送

// Each key represents xml tag from source xml file, except "xmlNode" and "values",
// Each value represents correspondent output xml tag,
$format = [
    "urun" => [ // Each <urun> tag,
        "xmlNode" => "item", // Gets converted to <item> tag,
        "values"  => [ // Has these children,
            "kategori" => "categoryTree",
            "urunadi"  => "name",
            "urunid"   => "code",
            "detay"    => "description",
            "resimler" => [ // Child with children,
                "xmlNode" => "pictures",
                "values"  => [
                    "resim" => "picture[]", // If name has [] in it, then this tag is a repeater. 
                ],
            ],
        ],
    ],
];

// Initiate class.
$instance = new XmlAligner();

// Source file.
$xml_file    = __DIR__ . '/../../storage/public/test.xml';

// Target Path.
$output_path = __DIR__ . '/../../storage/public/outputs/';

$result = $instance
    ->setDataStructure($format)
    ->setValidXmlFilePath($xml_file)
    ->setOutputPath($output_path)
    ->convert();

// Contains filename created with sha1 hash of the source file.
// Example: 20b5918bb61909f47c4ab14b44aecc9fd093fe43.xml
$instance->getOutputFileName()

测试

composer test

针对Windows

vendor\bin\paratest.bat

作者

许可证

该项目遵循MIT许可证 - 有关详细信息,请参阅LICENSE文件

实物软件

此软件包是实物软件。如果您在生产环境中使用它,我们要求您为世界买一棵树,以感谢我们的工作。通过为实物软件森林做出贡献,您将为当地家庭创造就业机会,并恢复野生动物栖息地。