Exemplo n.º 1
0
 /**
  * Returns an ezcsseStyle object for given XML string
  * 
  * @param string $source
  * @return ezcsseStyle
  */
 static function createFromXML($source)
 {
     $newObj = new ezcsseStyle();
     if ($source) {
         $dom = new DOMDOcument();
         $success = $dom->loadXML($source);
         $root = $dom->documentElement;
         if ($root->hasAttributes()) {
             foreach ($root->attributes as $attr) {
                 $newObj->setAttribute($attr->name, $attr->value);
             }
         }
         foreach ($root->childNodes as $node) {
             if ($node->nodeType == XML_ELEMENT_NODE && $node->nodeName == 'rule') {
                 $newObj->addRule(ezcsseRule::createFromXML($node));
             } elseif ($node->nodeType == XML_ELEMENT_NODE) {
                 $newObj->setAttribute($node->nodeName, $node->nodeValue);
             }
         }
     }
     return $newObj;
 }
Exemplo n.º 2
0
 /**
  * Creates a new ezcsseRule object from given XML node
  * 
  * @param DOMElement $node
  * @return ezcsseRule
  */
 static function createFromXML(DOMElement $node)
 {
     $newObj = new ezcsseRule();
     if ($node->hasAttributes()) {
         foreach ($node->attributes as $attr) {
             $newObj->setAttribute($attr->name, $attr->value);
         }
     }
     foreach ($node->childNodes as $node) {
         if ($node->nodeType == XML_ELEMENT_NODE && $node->nodeName == 'property') {
             $newObj->addProperty(ezcsseProperty::createFromXML($node));
         } elseif ($node->nodeType == XML_ELEMENT_NODE) {
             $newObj->setAttribute($node->nodeName, $node->nodeValue);
         }
     }
     return $newObj;
 }