attributes(); if (isset($attr['name'])) { $messages[trim($attr['name'])] = trim($msg); } } public function parse($xml) { $doc = @simplexml_load_string($xml); return $this->getMessages($doc); } public function getMessages($doc) { if (! $doc) { throw new Exception("Invalid XML structure in message bundle"); } $messages = array(); if (isset($doc->msg)) { foreach ($doc->msg as $msg) { $this->processMessage($messages, $msg); } } return $messages; } }