logifire / xml
Type safe XML reader using SimpleXMLElement internally
Installs: 15 284
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 1
Requires (Dev)
- phpunit/phpunit: ^7.4
README
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