rafaelnajera/xmlmatcher

Description of project xmlmatcher.

0.4 2017-03-01 09:33 UTC

This package is auto-updated.

Last update: 2024-10-19 02:16:51 UTC


README

Implements a Matcher\Token that matches XML elements out of an \XmlReader

Installation

Install the latest version with

$ composer require rafaelnajera/xmlmatcher

Usage

Use \Matcher\Pattern and \Matcher\PatternMatcher with XmlToken objects.

XmlToken provides three factory methods:

$token = XmlToken::elementToken('name');     // XML:  <name>
$token = XmlToken::endelementToken('name');  // XML: </name>
$token = XmlToken::textToken();              // XML: free text

Element tokens can also specify required attributes:

$token = XmlToken::elementToken('name')
    ->withReqAttrs([ ['a', 'value'], ['b', '*']); // XML: <name a="value" b="whatever">