定制 byjg/anydataset-xml 二次开发

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

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

byjg/anydataset-xml

最新稳定版本:6.0.0

Composer 安装命令:

composer require byjg/anydataset-xml

包简介

XML abstraction dataset for the AnyDataset library. AnyDataset is an agnostic data source abstraction layer in PHP.

README 文档

README

Sponsor Build Status Opensource ByJG GitHub source GitHub license GitHub release

XML abstraction dataset for the AnyDataset library. AnyDataset is an agnostic data source abstraction layer in PHP.

Features

  • Simple XML Processing: Process XML data with a clean, consistent API
  • XPath Support: Use XPath expressions to select nodes and attributes
  • Namespace Support: Full support for XML namespaces
  • Repeated Node Handling: Automatically handles repeated nodes by returning arrays
  • Custom Field Processing: Define custom field mappings with closures/callbacks
  • Flexible Input: Accept XML as string, DOMDocument, XmlNode, or File object
  • AnyDataset Integration: Compatible with the AnyDataset abstraction layer

Documentation

Installation

composer require "byjg/anydataset-xml"

Quick Example

<?php
$xml = file_get_contents('example.xml');

$dataset = new \ByJG\AnyDataset\Xml\XmlDataset(
    $xml,        // The XML string, can also be an XmlNode, DOMDocument, or File object
    "book",      // The node that represents a row
    [
        "category" => "@category",
        "title" => "title",
        "lang" => "title/@lang",
        "lang2" => function ($row) {
            return substr($row->get('lang'), 0, 2);
        }
    ] // Mapping columns
);

$iterator = $dataset->getIterator();
foreach ($iterator as $row) {
    echo $row->get('category'); // Print COOKING, CHILDREN, WEB
    echo $row->get('title');    // Print Everyday Italian, Harry Potter, Learning XML
    echo $row->get('lang');     // Print en-US, de-DE, pt-BR
    echo $row->get('lang2');    // Print en, de, pt
}

Dependencies

flowchart TD
    byjg/anydataset-xml --> byjg/anydataset
    byjg/anydataset-xml --> ext-dom
Loading

Running the Unit Tests

vendor/bin/phpunit

Open source ByJG

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-11-24