PHPackages                             abbotton/php-big-xml-parser - 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. abbotton/php-big-xml-parser

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

abbotton/php-big-xml-parser
===========================

使用PHP SAX Parser解析大型XML文件

v1.0.0(4y ago)222MITPHPPHP &gt;=5.6

Since Mar 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Abbotton/php-big-xml-parser)[ Packagist](https://packagist.org/packages/abbotton/php-big-xml-parser)[ Docs](https://github.com/abbotton/php-big-xml-parser)[ RSS](/packages/abbotton-php-big-xml-parser/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

PHP Big XML Parser
==================

[](#php-big-xml-parser)

PHP Fast XML Parser 是一个PHP扩展库，用于使用 PHP 解析大型 XML 文件。

特性:

- 轻量, 无第三方依赖;
- 灵活, 可以通过回调处理任意解析结果;
- 高性能, 极少的内存占用, 即使解析100MB大小的XML文件,内存占用也可以控制在10MB之内;

### 安装

[](#安装)

```
composer require abbotton/php-big-xml-parser
```

### 使用

[](#使用)

```
use Abbotton\BigXmlParser\GenericHandler;
use Abbotton\BigXmlParser\Parser;

// 创建handler
$handler = new GenericHandler;

// 设置解析完成回调
$handler->setOnItemParsedCallback(function ($item) {
    // $item变量包含解析的结果.
});

// 设置解析过程回调
$handler->setOnProgressCallback(function ($bytesProcessed, $bytesTotal) {
    // $bytesProcessed 已处理文件大小, 单位(byte)
    // $bytesTotal xml文件总大小, 单位(byte)
    // 可以通过计算获取当前处理进度.
});

// 创建解析器实例
$parser = new Parser($handler);

// 定义您不想包含在结果数组中的标签（可选）
$parser->setIgnoreTags(['root']);

// 为每个项目定义结束标签
// 这用作标记以确定何时处理 XML 项。
// 例如，如果你想从这个 XML 源中提取“值”
//
//    VALUE
//    VALUE
//    VALUE
//
// 你必须调用 $parser->setEndTag('value'),这样才能
// 在 "onItemParsed" 事件中返回每个  标签的内容。
$parser->setEndTag('value');

// 另一种情况, 假设您期望这个XML源中的value节点以数组形式返回
//
//
//        VALUE 1
//        VALUE 2
//        VALUE 3
//
//
// 则您必须调用$parser->setArrayTags(['value']), 这样才可以得到正确的结果.

// 开始解析
$parser->parse('bigfile.xml');
```

### Thanks

[](#thanks)

[Alex Oleshkevich](https://github.com/alex-oleshkevich)

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

1576d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16308633?v=4)[Abbotton](/maintainers/Abbotton)[@Abbotton](https://github.com/Abbotton)

---

Top Contributors

[![Abbotton](https://avatars.githubusercontent.com/u/16308633?v=4)](https://github.com/Abbotton "Abbotton (2 commits)")

---

Tags

large-xmlphpsax-parserxml-parserxmlphp xmlabbottonSAX XMLSAX-Parser

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/abbotton-php-big-xml-parser/health.svg)

```
[![Health](https://phpackages.com/badges/abbotton-php-big-xml-parser/health.svg)](https://phpackages.com/packages/abbotton-php-big-xml-parser)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k269.7M322](/packages/masterminds-html5)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k141.9M929](/packages/jms-serializer)[jms/metadata

Class/method/property metadata management in PHP

1.8k160.2M98](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k92.4M679](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

1.0k13.8M187](/packages/hassankhan-config)[sabre/xml

sabre/xml is an XML library that you may not hate.

55234.6M141](/packages/sabre-xml)

PHPackages © 2026

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