Saving XML to db

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi All,

What would be the best way to save XML to a database?

I mean I can use the example
' '.

they give a function to prevent any SQL Injection,

function quote_smart($value)
   // Stripslashes
   if (get_magic_quotes_gpc()) {
       $value = stripslashes($value);
   // Quote if not integer
   if (!is_numeric($value)) {
       $value = "'" . mysql_real_escape_string($value) . "'";
   return $value;

but then how do I get the data back, (as intended), from the db?
what would be the reverse of the above code?

Many thanks

Re: Saving XML to db

*** simon escribió/wrote (Fri, 11 Feb 2005 18:15:00 -0000):
Quoted text here. Click to load it


-+ Álvaro G. Vicario - Burgos, Spain
+- (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox

Re: Saving XML to db

Quoted text here. Click to load it

Sorry, what does that mean? is there no way to get the data back as
intended? So how would I save XML then?


Re: Saving XML to db

Quoted text here. Click to load it

The code tries to handle magic quotes settings (which IMHO is extremely
evil by default), so if $value isn't extracted from GET/POST/COOKIE it
will be wrongfully stripped.

Re: Saving XML to db

I would use a Native XML data base like's Xindice
( /) or DBXML ( /)

The advantage is the DOM of the XML is stored not the textual strings, so you
can search the XML data in the database using XML
constructs like XPATH (very cool).

I think both os these run in either the Jetty Java servlet container or under

I've heard, but not confirmed, that Oracle 8 and above can also provide an XML
schema capable of the same functions.

Quoted text here. Click to load it

Site Timeline