/** * This class method is used to construct a ResourceDescriptor object by providing the XML for that object. * * @param string $xml - XML String defining ResourceDescriptor * @return ResourceDescriptor */ public static function createFromXML($xml) { $sxi = new \SimpleXMLIterator($xml); $temp = new self((string) $sxi->attributes()->name, (string) $sxi->attributes()->wsType, (string) $sxi->attributes()->uriString, (string) $sxi->attributes()->isNew); $desc = !empty($sxi->description) ? (string) $sxi->description : null; $label = !empty($sxi->label) ? (string) $sxi->label : null; $date = !empty($sxi->creationDate) ? (string) $sxi->creationDate : null; $temp->setLabel($label); $temp->setDescription($desc); $temp->setCreationDate($date); foreach ($sxi->resourceDescriptor as $nestRd) { $temp->children[] = ResourceDescriptor::createFromXML($nestRd->asXML()); } foreach ($sxi->resourceProperty as $prop) { $temp->properties[] = ResourceProperty::createFromXML($prop->asXML()); } return $temp; }