src/Xml/Writer.php
public function addElement($name, $params, $parent)
    {
        $name = preg_replace("/_[0-9]+$/", "", $name);

        $element = $this->dom->createElement($name);

        if (!is_array($params)) {
            $this->setElementValue($element, $params);
        } else {
            foreach ($params as $key => $val) {
                if ($key == "_attributes") {
                    foreach ($val as $k => $v) {
                        $element->setAttribute($k, $v);
                    }
                } elseif ($key == "_value") {
                    $this->setElementValue($element, $val);
                } else {
                    $this->addElement($key, $val, $element);
                }
            }
        }

        $parent->appendChild($element);

        return $element;
    }
public function addElement($name, $params, $parent)
    {
        $name = preg_replace("/_[0-9]+$/", "", $name);

        $element = $this->dom->createElement($name);

        if (!is_array($params)) {
            $this->setElementValue($element, $params);
        } else {
            foreach ($params as $key => $val) {
                if ($key == "_attributes") {
                    foreach ($val as $k => $v) {
                        $element->setAttribute($k, $v);
                    }
                } elseif ($key == "_value") {
                    $this->setElementValue($element, $val);
                } else {
                    $this->addElement($key, $val, $element);
                }
            }
        }

        $parent->appendChild($element);

        return $element;
    }
public function addElement ( $ name , $ params , $ parent ) { $ name = preg_replace ( "/_[0-9]+$/" , "" , $ name ) ; $ element = $ this -> dom -> createElement ( $ name ) ; if ( ! is_array ( $ params ) ) { $ this -> setElementValue ( $ element , $ params ) ; } else { foreach ( $ params as $ key => $ val ) { if ( $ key == "_attributes" ) { foreach ( $ val as $ k => $ v ) { $ element -> setAttribute ( $ k , $ v ) ; } } elseif ( $ key == "_value" ) { $ this -> setElementValue ( $ element , $ val ) ; } else { $ this -> addElement ( $ key , $ val , $ element ) ; } } } $ parent -> appendChild ( $ element ) ; return $ element ; }
Append an element recursively to a dom instance.

@param string $name The name of the element to append
@param mixed $params The value to set the new element to, or the elements to append to it
@param mixed $parent The dom instance to append the element to

@return \DOMElement
Append an element recursively to a dom instance .