/** * Convert an Array to XML * @param string $node_name - name of the root node to be converted * @param array $arr - aray to be converterd * @return DomDocument */ public static function &createXML($node_name, $arr = array()) { $xml = self::getXMLRoot(); $xml->appendChild(self::convert($node_name, $arr)); self::$xml = null; // clear the xml node in the class for 2nd time use. return $xml; }
public function serialize($data, $rootNode = 'root') { if (is_array($data) && count($data) > 0) { $xml = ncArray2XML::createXML($rootNode, $data); return $xml->saveXML(); } return ''; }