Type safe XML reader using SimpleXMLElement internally

1.2.0 2020-03-26 07:43 UTC

This package is auto-updated.

Last update: 2024-04-26 16:52:51 UTC


README

Build Status

Example:

$xml = <<<XML
<root xmlns="https://example.org">
    <string attribute="first">Hello World</string>
    <int>100</int>
    <string attribute="second">Hello Internet</string>
</root>
XML;

$namespace = 'https://example.org';
$prefix = 'p';

$reader = Reader::create($xml, $namespace, $prefix);

// Absolute path
$reader->hasNode('/p:root'); // true

$reader->getString('/p:root/p:string[@attribute="first"]'); // Hello World

$reader->getInt('/p:root/p:int'); // 100

// Relative path
$collection = $reader->getCollection('/p:root/p:string');
$string_reader = $collection[0];

$string_reader->getName(); // string
$string_reader->getString('@attribute'); // first