xml2sql and xml-rpc
| From: | giancarlo pinerolo | Date: | Thu, 02 Aug 2001 18:23:34 +0000 |
| Subject: | xml2sql and xml-rpc | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-1255@lists.php.net to get a copy of this message | ||
I found there is a class used in the Experimental branch of PEAR. An
howto can be found at
http://www.nomad.ch/php/sql2xml
It provides DB resultsets, with tags in the form of
<row>
....
<row>
It is very interesting.
The XML-RPC data format is quite simple too, can do the same things and
a lot more I think.
there are no complex tags, no cdata, and there is that fantastic idea
which is the
<name></name> tag
The root of all tags is the value tag
<value></value> # a value the root
a value is defined inside that tag as
<value><*type*>ABCD</*type>
(type in that case would be 'string')
eg: an int value, unnamed
<value><int>18</int></value>
a string value, unnamed:
<value><string>Ciao!</string></value>
types are
string
int
double
base64
boolean
struct ## the most interesting
all except struct, are unnamed values.
a struct is the definition of a named variable
a struct contains one or more 'members', each one has a name and a value
tag
any value can contain itself a struct, so structs can be recursive
a named variable (struct), equivalent of the PHP
$loweBound=14;
<value>
<struct>
<member>
<name>lowerBound</name>
<value><int>18</int></value>
</member>
</struct>
A more complex structure.
Here is how is represented a the following PHP hash
$myarray["stringVar"]="...I am a string...";
$myarray["doubleVal"]=35.0346786;
<value>
<struct>
<member>
<name>myarray</name>
ù <value>
<struct>
<member>
<name>stringVar</name>
<value><string>...I am a string...</string>
</value>
</member>
<member>
<name>doubleVar</name>
<value><double>35.0346786</double></value>
</member>
</struct></value>
</member>
</struct></value>
this is like
with this you can build the whole world. Because you do not have/give
the possibility to 'invent tags' by unknown names:
you have a '<name></name>' tag for that!!
This is where XML-RPC is clever: a <name> a <value> and a <type> tag
I don't say ythat xml2sql is useless. It is more 'dedicate'. With XML_PC
you can do all you can do with xml2arr and more, not vv. You need one
parser for everything.
This can be used to return not only sql rows, but any complicate data
structure you can imagine, and PHP objects too.
Still, having a predefined set, limited number of tags, it is a lot
easier to handle
Giancarlo