Releases: veewee/xml
Version 2.12.0
Version 2.11.2
What's Changed
This commit reverts The more stable node loading from #61.
It turns out that this solution introduces some more problems.
It seems like a better idea to wait for a fix in PHP than to deal with these newer issues in this package.
Full Changelog: 2.11.1...2.11.2
Version 2.11.1
Version 2.11.0
What's Changed
- Explain how the reader component works by @veewee in #59
- Make namespace remover configurable by @veewee in #60
Full Changelog: 2.10.0...2.11.0
Version 2.10.0
Version 2.9.0
What's Changed
Provide nested matchers that represents parts of an XML tree.
It can be used similar to the //user
xpath operator to search on any matching node at any level in the XML
Given:
<root>
<users>
<user locale="nl">Jos</user>
<user>Bos</user>
<user>Mos</user>
</users>
</root>
This matcher will grab the user
element with locale="nl"
use \VeeWee\Xml\Reader\Matcher;
Matcher\nested(
// Breakpoint 1: <root />
Matcher\document_element(),
// Breakpoint 2: <user locale="nl">Jos</user>
// Searches for all elements that matches `<user />` and attribute `locale="nl"` in the `<root />` document.
// Note that you can skip matching on `<users />` here : it's not an exact matcher
Matcher\all(
Matcher\element_name('user'),
Matcher\attribute_value('locale', 'nl')
)
);
Every provided matcher acts as a breakpoint in the NodeSequence
for the next matcher,
making it composable with the exact XML tree sequence
matcher as well.
use \VeeWee\Xml\Reader\Matcher;
Matcher\nested(
// Breakpoint 1: <root />
Matcher\document_element(),
// Breakpoint 2: <user />
// The nested matcher will provide the NodeSequence starting from the element after previous match.
// The sequence will basically receive: 'users > user'
Matcher\sequence(
// Level 0: The element inside <root /> at level 0 must exactly match <users />
Matcher\element_name('users'),
// Level 1: The element inside <root /> at level 1 must exactly match <user />
Matcher\element_name('user'),
),
// Breakpoint 3: <email />
// After matching a sequence, you can still continue matching deeper or adding even more sequences:
Matcher\element_name('email')
);
Full Changelog: 2.8.0...2.9.0
Version 2.8.0
What's Changed
This release introduces a broad set of new and improved Reader matchers:
- all()
- any()
- attribute_local_name()
- attribute_local_value()
- attribute_name()
- attribute_value()
- document_element()
- element_local_name()
- element_name()
- element_position()
- namespaced_attribute()
- namespaced_attribute_value()
- namespaced_element()
- not()
- sequence()
Deprecates:
- node_attribute()
- node_name()
Example:
<root>
<users>
<user locale="nl">Jos</user>
<user>Bos</user>
<user locale="nl">Mos</user>
</users>
</root>
This matcher will grab the user
elements with locale="nl"
use VeeWee\Xml\Reader\Reader;
use \VeeWee\Xml\Reader\Matcher;
$matcher = Matcher\sequence(
// Level 0: <root />
Matcher\document_element(),
// Level 1: <users />
Matcher\element_name('users'),
// Level 2: <user locale="nl" />
Matcher\all(
Matcher\element_name('user'),
Matcher\attribute_value('locale', 'nl')
)
);
$matches = Reader::fromXmlFile($file)->provide($matcher);
Full Changelog: 2.7.0...2.8.0
Version 2.7.0
Version 2.6.0
What's Changed
Full Changelog: 2.5.0...2.6.0
2.5.0
What's Changed
Add document_uri DOM configurator by @veewee in #48
Allows you to keep track of the document uri, even if you are using an in-memory string.
Internally, it sets DOMDocument::$documentURI
, which gets used as file
in the error handling issues component.
use VeeWee\Xml\Dom\Document;
use function VeeWee\Xml\Dom\Configurator\document_uri;
$wsdl = 'http://myservice.com?wsdl';
Document::fromXmlString(
$loadFromHttp($wsdl),
document_uri($wsdl)
);
Add 'expect*' shortcut functions to NodeList by @veewee in #47
Provides shortcut functions to the NodeList
that allow you to grab a single element OR throw a customizable exception instead.
$item = $list->expectAt(0, 'Expected an element at index %s');
$item = $list->expectFirst('Expected a first element.');
$item = $list->expectSingle('Expected exactly 1 element, got %s');
$item = $list->expectLast('Expected an element at index %s');
Full Changelog: 2.4.0...2.5.0