Skip to content

Version 2.8.0

Compare
Choose a tag to compare
@veewee veewee released this 30 Oct 12:40
2.8.0
a425c77

What's Changed

  • Provide better reader matchers by @veewee in #55

This release introduces a broad set of new and improved Reader matchers:

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