×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Store XML Object in MySQL

Store XML Object in MySQL

Store XML Object in MySQL

(OP)
Working on an API integration where responses are received in XML. There could be any number of sources and each have their own format.

Now, since I am dealing with 45 to 50 different sources, I figure that the best option would be to extract from each whatever I may need for searching/indexing purpose and store the entire XML Object in a column.

The idea is that once the XML content is needed, I can/should simply extract the object from the column, just as you would any other column, and do what needed.

For the life of me, I have search high and low and a couple of hours later, all I find is suggestions to parse the XML document and store the individual values ... but as I said, no two of these people use identical format.

If I save it in a BLOB field, how then do I read it later? is this possible at all?

--
SouthBeach
http://www.fp2php.com
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.

RE: Store XML Object in MySQL

Hi

blob ? Binary Large Object ? But XML is text. Why not use a field of type text instead ?

Feherke.
feherke.ga

RE: Store XML Object in MySQL

You can store it in a blob field if you want to, but as Feherke points out a Text field in MYSQL may be more adequate for XML.

As to how you read it, you read it like you read any field in MYSQL. Run a select to get the field you want and read the XML. Since XML is just text, once you get it back from the query and into a variable you can do with it whatever you want.


----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech

RE: Store XML Object in MySQL

(OP)
I have tried both, text and blob but nothing seem to be stored.

Come to think of it, I am not serializing nor escaping it ... Let me try that!

--
SouthBeach
http://www.fp2php.com
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.

RE: Store XML Object in MySQL

(OP)
So, the problem was my attempting to store simplexml object instead of the XML document itself.

Spotting this was one of those moment ...

--
SouthBeach
http://www.fp2php.com
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close