cvs: pear /XML_sql2xml sql2xml.php
| From: | Christian Stocker | Date: | Fri, 17 Aug 2001 15:25:07 +0000 |
| Subject: | cvs: pear /XML_sql2xml sql2xml.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-562@lists.php.net to get a copy of this message | ||
chregu Fri Aug 17 11:25:07 2001 EDT
Modified files:
/pear/XML_sql2xml sql2xml.php
Log:
api change in domxml... this should work with php 4.0.7 and lower versions
Index: pear/XML_sql2xml/sql2xml.php
diff -u pear/XML_sql2xml/sql2xml.php:1.4 pear/XML_sql2xml/sql2xml.php:1.5
--- pear/XML_sql2xml/sql2xml.php:1.4 Thu Aug 16 13:12:44 2001
+++ pear/XML_sql2xml/sql2xml.php Fri Aug 17 11:25:07 2001
@@ -15,7 +15,7 @@
// | Authors: Christian Stocker <chregu@phant.ch> |
// +----------------------------------------------------------------------+
//
-// $Id: sql2xml.php,v 1.4 2001/08/16 17:12:44 chregu Exp $
+// $Id: sql2xml.php,v 1.5 2001/08/17 15:25:07 chregu Exp $
/**
* This class takes a PEAR::DB-Result Object, a sql-query-string or an array
@@ -48,7 +48,7 @@
* http://php.chregu.tv/sql2xml
*
* @author Christian Stocker <chregu@nomad.ch>
-* @version $Id: sql2xml.php,v 1.4 2001/08/16 17:12:44 chregu Exp $
+* @version $Id: sql2xml.php,v 1.5 2001/08/17 15:25:07 chregu Exp $
* @package XML
*/
class XML_sql2xml {
@@ -168,7 +168,9 @@
* (note that domxml at the moment only support UTF-8, or at least it looks like)
*/
var $encoding_to = "UTF-8";
-
+
+ var $tagname = "tagname";
+
/**
* Constructor
* The Constructor can take a Pear::DB "data source name" (eg.
@@ -221,6 +223,11 @@
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";
+ }
}
}
@@ -393,7 +400,6 @@
}
// the method_exists is here, cause tableInfo is only in the cvs at the moment
- // (should be in 4.0.6)
// BE CAREFUL: if you have fields with the same name in different tables, you will get
errors
// later, since DB_FETCHMODE_ASSOC doesn't differentiate that stuff.
$this->LastResult = &$result;
@@ -609,7 +615,16 @@
if ($this->xmlroot)
return $this->xmlroot->new_child($this->tagNameResult, NULL);
else
- return $this->xmldoc->add_root($this->tagNameResult);
+ {
+ $this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);
+ //PHP 4.0.6 had $root->name as tagname, check for that here...
+ if (!isset($this->xmlroot->{$this->tagname}))
+ {
+ $this->tagname = "name";
+ }
+ return $this->xmlroot;
+
+ }
}
@@ -747,9 +762,12 @@
function doXmlString2Xml ($string)
{
$MainXmlString = $this->xmldoc->dumpmem();
+
$string = preg_replace("/<\?xml.*\?>/","",$string);
- $MainXmlString =
preg_replace("/<".$this->xmlroot->name."\/>/","<".$this->xmlroot->name."></".$this->xmlroot->name.">",$MainXmlString);
- $MainXmlString =
preg_replace("/<\/".$this->xmlroot->name.">/",$string."</".$this->xmlroot->name.">",$MainXmlString);
+
+ $MainXmlString =
preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);
+ $MainXmlString =
preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);
+
$this->xmldoc = xmldoc($MainXmlString);
$this->xmlroot = $this->xmldoc->root();
}