chrisullyott/php-xml

PHP中的XML到数组转换。

v2.0.0 2019-12-30 15:59 UTC

This package is auto-updated.

Last update: 2024-08-29 03:29:59 UTC


README

PHP中的XML到数组转换。专为从各种RSS源中提取项目而构建。

安装

使用Composer

$ composer require chrisullyott/php-xml

用法

use ChrisUllyott\XmlParser;

$parser = new XmlParser('path/to/feed.xml'); // or pass in a raw XML string

$items = $parser->getItems();

print_r($items);

每个源项及其子属性将被解析成扁平结构

(
    [0] => Array
        (
            [title] => News for September the Second
            [link] => http://example.com/2002/09/01/news-for-september-the-second
            [guid] => 20020901-news-for-september-the-second
            [guid_isPermaLink] => 0
            [description] => Things happened today!
        )

    [1] => Array
        (
            [title] => News for September the First
            [link] => http://example.com/2002/09/01/news-for-september-the-first
            [guid] => 20020901-news-for-september-the-first
            [guid_isPermaLink] => 0
            [description] => Things happened today!
        )

)