public function parseCategory($xml) { $cat = new Category(); $cat->setInfos($this->getAttributes($xml)); while ($xml->read()) { if ($xml->nodeType == XMLReader::ELEMENT) { switch ($xml->localName) { case 'Category': $cat->addCategory($this->parseCategory($xml)); break; } } else { if ($xml->nodeType == XMLReader::END_ELEMENT) { if ($xml->localName == 'Category') { break; } } } } return $cat; }