How can we load data to Mysql Tables from XML Files?? Is there any way to read data from XML Files and Write to MySql database.. I have a bulk of data in XML Files.
Thanks in Advance for help.
How can we load data to Mysql Tables from XML Files?? Is there any way to read data from XML Files and Write to MySql database.. I have a bulk of data in XML Files.
Thanks in Advance for help.
Try the LOAD XML function (MySQL 6.0). Here's the sample code from the reference manual:
Using an XML document person.xml containing:
you would create a table like so:
and use the following command to import the XML:
Or if you're running MySQL 5.0 you can use LOAD_FILE to load the entire XML document as a string into a single column, and then parse it using MySQL's XPath functionality.
This article on MySQL.com has more details: Using XML in MySQL 5.1 and 6.0.
If your looking for a simple solution, Navicat has a pretty simple xml import function.
Why not use XSL to translate the XML into standard SQL insert statements, then use the "source" command from within the mysql client to read the output?