Thursday, November 15, 2012

Answers > How Can I Convert XML Files Into Information That Can Be Put in an MySQL Database?

How Can I Convert XML Files Into Information That Can Be Put in an MySQL Database?

by nForms on November 28, 2011

I am working on a website that gets it's information from an XML datafeed. It would be a lot easier to work with if I could insert the XML data into a MySQL database. Could somebody tell me how I could do this or point me in the direction of an article or something that could tell me?

Tags: , , , , , ,

Similar XForms | XML Posts

{ 2 comments… read them below or add one }

HandyManOrNot June 30, 2011 at 12:00 pm

First off, because XML is just text, you could insert the entire document in a large text field in the database.

Second, if you have an application server such as a Java J2EE server, you could use Java’s JDOM API to strip the data from the XML and store it in the appropriate custom database fields.

Third, most major databases (I am not sure about MySQL) have an interactive XML functionality that lets you submit XML in a specific format and the DB engine will translate the data into the appropriate DB fields. If necessary, you could use an XSL Transformation to trn the XML from the feed into the format required by the database.

None of this is trivial. I googled "storing XML in MySQL database" and got so many relevant looking hits I simply suggest you do the same. Read them all and you will surely find the info you need.

Mike June 30, 2011 at 12:00 pm

You need a script or program that would parse the XML file, extract the relevant fields, build a SQL query and post the data in the database.
You can use a bunch of tools out there to do that. Try Python.

Previous post:

Next post: