A PHP library that provides a nicer, lightweight wrapper around PHP's native XML API.
composer install neoncitylights/xml
- PHP 8.3+
- libxml (enabled by default in PHP)
<?php
use Neoncitylights\Xml\Encoding;
use Neoncitylights\Xml\XmlNativeParser;
// create a parser normally, or with an XML namespace
$parser = XmlNativeParser::new(Encoding::Utf8);
$parserNs = XmlNativeParser::newWithNamespace(Encoding::Utf8, ':');
// parse XML
$xmlFileStream = \fopen('example.xml');
while (($data = \fread($xmlFileStream, 16384))) {
$parser->parse($data); // parse the current chunk
}
$parser->parseFinalize();
\fclose($xmlFileStream);
Neoncitylights\Xml\Encoding
- A string enum of the possible XML text encodings.Neoncitylights\Xml\ErrorCode
- An integer enum of the possible XML error codes, backed by core constants.Neoncitylights\Xml\Option
- An integer enum of the possible XML options that can be get or set, backed by core constants.Neoncitylights\Xml\XmlNativeParser
- A class that wraps around the nativeXmlParser
class and built-in XML parsing functions.Neoncitylights\Xml\XmlParseResult
- A class that represents the values passed-by-reference from thexml_parse_into_struct()
function.
This software is licensed under the MIT license (LICENSE
or http://opensource.org/licenses/MIT).
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions.