private static function parseElement(CharStream $s, Listener $l, $currentContainer = null) { $l->beginElement($currentContainer); $line = self::parseLine($s, $l); if (!$line) { return null; } list($key, $value) = $line; $lowerKey = mb_strtolower($key); if ($lowerKey == 'begin') { return $l->endElement(self::parseContainer($s, $l, trim($value))); } else { if ($lowerKey == 'end' && mb_strtolower(trim($value)) == mb_strtolower($currentContainer)) { return null; } else { return $l->endElement(self::parseProperty($l, $key, $value)); } } }