digitalkaoz/xml-filter 问题修复 & 功能扩展

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

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

digitalkaoz/xml-filter

Composer 安装命令:

composer require digitalkaoz/xml-filter

包简介

filter data out of xml documents

README 文档

README

this library lets you filter complex Data-Structures out of XML Documents into some Array Structure (nested Arrays, Maps, Strings ...).

  • It is capable of using different XML Backends (\SimpleXml* or \Dom* or even your Own)
  • It has Support for Type-Casting, Sorting, Validation, Reference-Checking, Conditional-Inclusion, Post-Processing, Merging, Aggregating and ...
  • It is extendable (it uses Pimple behind the curtain), so you can provide your own Filter, or override nearly every part

Build Status Dependency Status Scrutinizer Code Quality Code Coverage SensioLabsInsight Latest Stable Version Total Downloads StyleCI

Installation

$ composer install

Example

Given I Have the following XML Document

<doc>
    <foo>foo</foo>
    <bar>20</bar>
    <bar>30</bar>
    <bar>10</bar>
</doc>

When I use the following Configuration (while using the Yaml Loader)

Rs\XmlFilter\Filter\AggregateFilter:
    mappings:
        bazz:
            filter: Rs\XmlFilter\Filter\AggregateFilter
            mappings:
                foo: "/doc/foo"
        bar:
            path: "/doc/bar"
            cast: "int"
            sort: true
            multiple: true

I want to get the following Array after filtering

[
    'bazz' => [
        'foo' => 'foo',
    ],
    'bar' => [10, 20, 30]
]

Parse a RSS Feed

Rs\XmlFilter\Filter\MapFilter:
  basePath: //channel/item
  key: ./guid
  value:
    filter: Rs\XmlFilter\Filter\AggregateFilter
    mappings:
      title: ./title
      link: ./link
      category: ./category
      date: ./pubDate
      text:
        filter: Rs\XmlFilter\Filter\PostFilter
        callable: strip_tags
        real_filter:
          filter: Rs\XmlFilter\Filter\ScalarFilter
          path: ./description
$filter = \Rs\XmlFilter\XmlFilter::create();

$doc = $filter::load(file_get_contents('https://news.google.de/?output=rss'));
$config = new \Rs\XmlFilter\Loader\YamlLoader(__DIR__ . '/rss.yml');

$result = $filter->filter($doc, $config);

echo json_encode($result, JSON_PRETTY_PRINT);

Usage

PHAR

to build a phar simply run

$ composer build

Tests

$ composer test-all

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固