/** * @throws Exception * @param SimpleDOM $root * @param $node * @return Shopware_Components_Xml_SimpleXml */ public function set(SimpleDOM $root,$node){ if (!is_array($node)){ throw new Exception("\$node is not an array"); } if (!empty($node["@attributes"])){ $attributes = $node["@attributes"]; unset($node["@attributes"]); }else { $attributes = array(); } foreach ($node as $key => $value){ if (!empty($value["@attributes"])){ $attributes = $value["@attributes"]; }else { $attributes = array(); } if (is_string($value)){ $root->addChild($key,$value); }elseif (is_array($value)){ $childNode = $root->addChild($key); if (isset($attributes)){ foreach ($attributes as $attrKey => $attrValue){ $childNode->addAttribute($attrKey,$attrValue); } unset($attributes); } $this->set($childNode,$value); } } return $this; }