-
Notifications
You must be signed in to change notification settings - Fork 20
XMLReader
FluentDOM\XMLReader
extends XMLReader with some namespace support.
public function read(string $name = NULL, string $namespaceUri = NULL, callable $filter = NULL)
FluentDOM\XMLReader::read()
now allows you to provide a tag name, a namespace URI and
a filter function.
public function next(string $name = NULL, string $namespaceUri = NULL, callable $filter = NULL)
FluentDOM\XMLReader::next() had the $name
parameter, already. It got namespace URI and
a filter function added.
public function registerNamespace(string $prefix, string $namespace)
This method registers a namespace on the XMLReader
itself. This allows other methods to resolve prefixes in tag name arguments. The namespaces are propagated to FluentDOM\DOM\Document
instances created by expand()
.
FluentDOM now implements two iterators that abstract the XMLReader::read()
/XMLReader::next()
and
XMLReader::expand()
. The FluentDOM\XMLReader\Iterator
iterates over all nodes that match the
filters the value provided by the iterator is the expanded DOM node.
FluentDOM\SiblingIterator
will iterate over the siblings of the first matched node. It will
not go into child or parent nodes.
The improvements may not look like much, but they considerably reduce the source needed for an implementation.
$reader = new FluentDOM\XMLReader();
$reader->open($file);
$reader->registerNamespace('s', 'http://www.sitemaps.org/schemas/sitemap/0.9');
$reader->registerNamespace('v', 'http://www.google.com/schemas/sitemap-video/1.1');
foreach (new FluentDOM\XMLReader\SiblingIterator($reader, 's:url') as $url) {
var_dump(
[
$url('string(v:video/v:title)'),
$url('string(s:loc)')
]
);
}
- Home
- Getting Started
- Tasks
- Plugins
- Functions
- Lists
- Creator (5.1)
- CSS Selectors
- Convertors
- Loaders
- Serializers (5.1)
- Transformers (5.1)
- Extended DOM
- XMLReader (6.1)
- XMLWriter (6.1)
- Interfaces