protected function convertXmlToArray($xml) { if (!is_object($xml)) { $xml = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); } $result = (array) $xml; foreach ($result as $key => $value) { if (is_object($value)) { $result[$key] = $this->convertXmlToArray($value); } } return $result; }