https://github.com/alex-oleshkevich/php-fast-xml-parser
Fast SAX XML parser for PHP.
https://github.com/alex-oleshkevich/php-fast-xml-parser
parsing php sax sax-parser xml
Last synced: 3 months ago
JSON representation
Fast SAX XML parser for PHP.
- Host: GitHub
- URL: https://github.com/alex-oleshkevich/php-fast-xml-parser
- Owner: alex-oleshkevich
- License: mit
- Created: 2014-10-07T18:51:26.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-02-24T20:26:03.000Z (over 2 years ago)
- Last Synced: 2025-03-12T13:46:53.804Z (3 months ago)
- Topics: parsing, php, sax, sax-parser, xml
- Language: PHP
- Homepage:
- Size: 22.5 KB
- Stars: 31
- Watchers: 7
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PHP Fast XML Parser
=========PHP Fast XML Parser is a PHP library for parsing large XML files using PHP.
Key features:- Lightweight;
- Flexible (result can be easily managed via callback handlers);
- Good for memory critical projects (~10Mb in average while parsing 500mb XML file)
[](https://travis-ci.org/alex-oleshkevich/php-fast-xml-parser)## Installation
```
composer require alex.oleshkevich/fast-xml-parser
```Example & Tutorial
--------------```php
setOnItemParsedCallback(function ($item) use ($self) {
// do smth with parsed item
});// set "on progress" callback
$handler->setOnProgressCallback(function ($bytesProcessed, $bytesTotal) use ($self) {
// eg. draw a progress bar
});// instantiate
$parser = new Parser($handler);// define tags which you don't want to include in resulting array (optional)
$parser->setIgnoreTags(['root']);// define end tag for every item
// (this is used as marker to determine when XML
// item was processed.
// For example, if you want to extract "value" from this XML source
//
// VALUE
// VALUE
// VALUE
//
// you must call $parser->setEndTag('value') so library can
// emit content of every tag in "onItemParsed" event.
$parser->setEndTag('value');// run
$parser->parse('bigfile.xml');
```