/** * This function creates the XML recursively through this object and all children objects within. */ private function newXML() { $result = new \SimpleXMLElement('<resourceDescriptor></resourceDescriptor>'); foreach ($this->_rootAttributes as $k => $v) { if (!empty($v)) { $result->addAttribute($k, $v); } } if (!empty($this->label)) { $result->addChild('label', $this->label); } if (!empty($this->description)) { $result->addChild('description', $this->description); } if (!empty($this->creationDate)) { $result->addChild('creationDate', $this->creationDate); } if (count($this->children) > 0) { foreach ($this->children as $child) { ResourceDescriptor::sxml_append($result, $child->newXML()); } } if (count($this->properties) > 0) { foreach ($this->properties as $property) { ResourceDescriptor::sxml_append($result, $property->newXML()); } } return $result; }