/** * packXML::packXML() - constructor * * @return void */ function packXML($rootName){ //create xml parser $this->xml = domxml_new_xmldoc('1.0'); //set root node $this->root = domxml_add_root($this->xml,$rootName); }
/** * Constructor * The Constructor can take a Pear::DB "data source name" (eg. * "mysql://*****:*****@localhost/dbname") and will then connect * to the DB, or a PEAR::DB object link, if you already connected * the db before. " If you provide nothing as $dsn, you only can later add stuff with * a pear::db-resultset or as an array. providing sql-strings will * not work. * the $root param is used, if you want to provide another name for your * root-tag than "root". if you give an empty string (""), there will be no * root element created here, but only when you add a resultset/array/sql-string. * And the first tag of this result is used as the root tag. * * @param mixed $dsn PEAR::DB "data source name" or object DB object * @param string $root the name of the xml-doc root element. * @access public */ function XML_sql2xml($dsn = Null, $root = 'root') { // if it's a string, then it must be a dsn-identifier; if (is_string($dsn)) { include_once 'DB.php'; $this->db = DB::Connect($dsn); if (DB::isError($this->db)) { print "The given dsn for XML_sql2xml was not valid in file " . __FILE__ . " at line " . __LINE__ . "<br>\n"; return new DB_Error($this->db->code, PEAR_ERROR_DIE); } } elseif (is_object($dsn) && DB::isError($dsn)) { print "The given param for XML_sql2xml was not valid in file " . __FILE__ . " at line " . __LINE__ . "<br>\n"; return new DB_Error($dsn->code, PEAR_ERROR_DIE); } elseif (strtolower(get_parent_class($dsn)) == 'db_common') { // if parent class is db_common, then it's already a connected identifier $this->db = $dsn; } $this->xmldoc = domxml_new_xmldoc('1.0'); //oehm, seems not to work, unfortunately.... does anybody know a solution? $this->xmldoc->encoding = $this->encoding_to; if ($root) { $this->xmlroot = $this->xmldoc->add_root($root); //PHP 4.0.6 had $root->name as tagname, check for that here... if (!isset($this->xmlroot->{$this->tagname})) { $this->tagname = 'name'; } } }