elementMap['{urn:test}collection'] = function($reader) { return repeatingElements($reader, '{urn:test}item'); }; $xml = << foo bar XML; $result = $service->parse($xml); $expected = [ 'foo', 'bar', ]; $this->assertEquals($expected, $result); } }