Download the PHP package sbwerewolf/xml-navigator without Composer
On this page you can find all versions of the php package sbwerewolf/xml-navigator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sbwerewolf/xml-navigator
More information about sbwerewolf/xml-navigator
Files in sbwerewolf/xml-navigator
Package xml-navigator
Short Description Easy XML to PHP array conversion and fast XML streaming conversion
License Apache-2.0
Informations about the package xml-navigator
Xml Navigator
The PHP library Xml Navigator
base on XMLReader
.
You can assign XML as string or as URI ( or file system path to file).
Navigator can provide XML-document as array or as object.
How to use
OUTPUT:
How To Install
composer require sbwerewolf/xml-navigator
Use cases
XML file processing with no worries of file size
Access time to first element do not depend on file size.
Let explain this with example.
First generate XML files by script:
Now, run benchmark by script:
Parse XML fast with callback for detect suitable elements
Output to console will be:
XML-document as array
XmlConverter implements array approach.
XmlConverter can use to convert XML-document to array, example:
OUTPUT:
XML-document as object
XmlElement implements object-oriented approach.
Navigator API
name(): string
// Returns the name of XML elementhasValue(): bool
// Returnstrue
if XML element has valuevalue(): string
// Returns the value of XML elementhasAttribute(string $name = ''): bool
// Returnstrue
if XML element has attribute with$name
. If$name
omitted, than returnstrue
if XML element has any attributeattributes(): XmlAttribute[]
// Returns all attributes of XML elementget(string $name = null): string
// Get value of attribute with the$name
, if$name
is omitted, than returns value of random attributehasElement(?string $name = null): bool
// Returnstrue
if XML element has nested element with$name
. If$name
omitted, than returnstrue
if XML element has any nested elementelements(): IXmlElement[]
// Returns all nested elementspull(string $name = ''): Generator
// PullIXmlElement
for nested element, if$name
is defined, than pull elements with the$name
Interact with XML as object
Advanced using
Unit tests have more examples of using, please investigate them.
Run tests
Contacts
All versions of xml-navigator with dependencies
sbwerewolf/language-specific Version 8.4.*
ext-xmlreader Version *
ext-libxml Version *
sbwerewolf/json-serialize-trait Version ^1