src/Domi/Domi.php
public function attachToXml($data, $prefix, &$parentNode = false)
    {
        if (!$parentNode) {
            $parentNode = &$this->mainNode;
        }
        // i don't like how this is done, but i can't see an easy alternative
        // that is clean. if the prefix is attributes, instead of creating
        // a node, just put all of the data onto the parent node as attributes
        if (strtolower($prefix) == 'attributes') {
            // set all of the attributes onto the node
            foreach ($data as $key=>$val) {
                $parentNode->setAttribute($key, $val);
            }

            $node = &$parentNode;
        } else {
            $node = $this->convertToXml($data, $prefix);
            $parentNode->appendChild($node);
        }
        return $node;
    }
public function attachToXml($data, $prefix, &$parentNode = false)
    {
        if (!$parentNode) {
            $parentNode = &$this->mainNode;
        }
        // i don't like how this is done, but i can't see an easy alternative
        // that is clean. if the prefix is attributes, instead of creating
        // a node, just put all of the data onto the parent node as attributes
        if (strtolower($prefix) == 'attributes') {
            // set all of the attributes onto the node
            foreach ($data as $key=>$val) {
                $parentNode->setAttribute($key, $val);
            }

            $node = &$parentNode;
        } else {
            $node = $this->convertToXml($data, $prefix);
            $parentNode->appendChild($node);
        }
        return $node;
    }
public function attachToXml ( $ data , $ prefix , & $ parentNode = false ) { if ( ! $ parentNode ) { $ parentNode = & $ this -> mainNode ; } // i don't like how this is done, but i can't see an easy alternative // that is clean. if the prefix is attributes, instead of creating // a node, just put all of the data onto the parent node as attributes if ( strtolower ( $ prefix ) == 'attributes' ) { // set all of the attributes onto the node foreach ( $ data as $ key => $ val ) { $ parentNode -> setAttribute ( $ key , $ val ) ; } $ node = & $ parentNode ; } else { $ node = $ this -> convertToXml ( $ data , $ prefix ) ; $ parentNode -> appendChild ( $ node ) ; } return $ node ; }
the heart of DOMi - take a complex data tree and build it into an
XML tree with the specified prefix and attach it to either the
specified node or the root node

@param mixed any PHP data type that is being converted to XML
@param string the name of the node that the data will be built onto
@param DOMNode node to attach the newly created onto
@retval DOMNode the newly created node
the heart of DOMi - take a complex data tree and build it into an XML tree with the specified prefix and attach it to either the specified node or the root node