Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dkrnl/simplexmlreader
Wrapped XMLReader class, for simple SAX-reading of huge xml.
https://github.com/dkrnl/simplexmlreader
Last synced: 1 day ago
JSON representation
Wrapped XMLReader class, for simple SAX-reading of huge xml.
- Host: GitHub
- URL: https://github.com/dkrnl/simplexmlreader
- Owner: dkrnl
- Created: 2012-01-12T10:31:26.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2023-06-05T13:07:08.000Z (over 1 year ago)
- Last Synced: 2024-10-30T20:05:19.068Z (15 days ago)
- Language: PHP
- Homepage:
- Size: 142 KB
- Stars: 112
- Watchers: 9
- Forks: 43
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Simple XML Reader
Wrapper XMLReader(http://php.net/manual/ru/book.xmlreader.php) class, for simple **SAX**-reading(and simple **XPath**-queries) of **huge**(testing over 1G file) xml.
**Minimum the memory** usage of other xml libraries(SimpleXML, DOMXML).
Usage example 1:
```php
$reader = new SimpleXMLReader;
$reader->open("big.xml");
$reader->registerCallback("by-node-name", function($reader) {
$element = $reader->expandSimpleXml(); // copy of the current node as a SimpleXMLElement object
$attributes = $element->attributes(); // read element attributes
/* ...your code here... */
return true;
});
$reader->registerCallback("/by/xpath/query", function($reader) {
$element = $reader->expandDomDocument(); // copy of the current node as a DOMNode object
$attributes = $element->attributes(); // read element attributes
/* ...your code here... */
return true;
});
$reader->parse();
$reader->close();```
Usage example 2: http://github.com/dkrnl/SimpleXMLReader/blob/master/examples/example1.phpLicense: Public Domain