suramon / simple-xml-reader
The power of SimpleXmlElement, combined with the resource-friendliness of XmlReader
Installs: 89 565
Dependents: 1
Suggesters: 0
Security: 0
Stars: 8
Watchers: 2
Forks: 6
Open Issues: 1
Requires
- php: >=5.3
Requires (Dev)
- phpunit/phpunit: ~3
This package is not auto-updated.
Last update: 2024-10-26 15:31:09 UTC
README
Interface for the PHP XML Pull parser XMLReader that adds super-simplified xpath functionality. This is ideal for reading huge xml files without the memory costs of other xml libraries (eg SImpleXMLElement).
Example
source code: https://github.com/SuRaMoN/simplexmlreader/blob/master/examples/simple-example.php
$xml = SimpleXmlReader::openFromString(' <root> <animal type="cat"> <hastail>yes</hastail> </animal> <animal type="dog"> <hastail>yes</hastail> </animal> <animal type="kakariki"> <hastail>no</hastail> </animal> </root> '); foreach($xml->path('root/animal') as $animal) { // $animal is of type SimpleXMLElelent // only the current iterated $animal is in memory, so huge xml files can be read, without much memory consumption echo "A {$animal->attributes()->type} has a tail? {$animal->hastail}!\n"; }