PHPackages                             hedeqiang/xml - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. hedeqiang/xml

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

hedeqiang/xml
=============

xml解析

0.0.5(7y ago)21101MITPHPPHP &gt;=7.0

Since Dec 24Pushed 6y agoCompare

[ Source](https://github.com/hedeqiang/xml)[ Packagist](https://packagist.org/packages/hedeqiang/xml)[ RSS](/packages/hedeqiang-xml/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)Dependencies (2)Versions (7)Used By (0)

 xml
=====

[](#-xml-)

 xml 创建、解析

来自超哥 [EasyWechat](https://github.com/overtrue/wechat)

[![Build Status](https://camo.githubusercontent.com/ad3d998fe662be8575d0b6588b911b276bfb0d85a451860fae6b2d2cf2f2c5e9/68747470733a2f2f7472617669732d63692e6f72672f686564657169616e672f786d6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hedeqiang/xml)[![StyleCI](https://camo.githubusercontent.com/4eb0f9462b9cc7b5e2f89fd877d39f21504f5a8d1c29f0931193150d5434b826/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3136323938303933322f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/162980932)[![FOSSA Status](https://camo.githubusercontent.com/f573abed88f14436c85173dc5d970170c53ebfce3b4e06bbb2c6c785c405bfdf/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f6769742532426769746875622e636f6d253246686564657169616e67253246786d6c2e7376673f747970653d736869656c64)](https://app.fossa.io/projects/git%2Bgithub.com%2Fhedeqiang%2Fxml?ref=badge_shield)

Installing
----------

[](#installing)

```
$ composer require hedeqiang/xml -vvv
```

Usage
-----

[](#usage)

### 解析XML，返回数组

[](#解析xml返回数组)

```
require __DIR__ .'/vendor/autoload.php';

use Hedeqiang\Xml\Xml;

$xml = "
        name
        age

    ";
print_r(xml::parse($xml)) ;
```

### 创建XML

[](#创建xml)

```
$data = [
    'id' => 'bk101',
    'author' => 'Gambardella, Matthew',
    'title' => 'XML Developer\'s Guide',
    'genre' => 'Computer',
    'price' => '44.95',
    'items' => ['foo', 'bar'],
    'publish_date' => '2000-10-01',
    'description' => 'An in-depth look at creating applications with XML.',
];
print_r(xml::build($data));
```

鸣谢
--

[](#鸣谢)

该内容来自超哥 [EasyWechat](https://github.com/overtrue/wechat) ,因业务需要解析xml数据，网上找到一个关于解析的，无奈该扩展xml 数据源不能从接口获取，So 把超哥的代码搬过来了.原封不动，就连测试用例也搬过来了......

[Rodenastyle/stream-parser](https://github.com/Rodenastyle/stream-parser) ，另外刚才说的扩展就是这个，如果你是读取一个xml文件的话，可以使用这个扩展

License
-------

[](#license)

MIT

[![FOSSA Status](https://camo.githubusercontent.com/cc6b2522c541d49308c9f59ef908e17c9ac9556388a747441ed220538fa69273/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f6769742532426769746875622e636f6d253246686564657169616e67253246786d6c2e7376673f747970653d6c61726765)](https://app.fossa.io/projects/git%2Bgithub.com%2Fhedeqiang%2Fxml?ref=badge_large)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

2700d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ac33cc87fe5ba7f0b8791f5b3453501e83b55ec9a5a209728817ff119635a72?d=identicon)[hedeqiang](/maintainers/hedeqiang)

---

Top Contributors

[![hedeqiang](https://avatars.githubusercontent.com/u/31909061?v=4)](https://github.com/hedeqiang "hedeqiang (16 commits)")[![fossabot](https://avatars.githubusercontent.com/u/29791463?v=4)](https://github.com/fossabot "fossabot (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hedeqiang-xml/health.svg)

```
[![Health](https://phpackages.com/badges/hedeqiang-xml/health.svg)](https://phpackages.com/packages/hedeqiang-xml)
```

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M345](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
