MySQL: How to import XML File Data into a Table?

In this post, I am going to import XML file data into a table of MySQL Database.

MySQL provides LOAD XML INFILE to import XML file data into a table. We can use ROWS IDENTIFIED BY clause to read row by providing a XML node.
It supports three different type of XML formats.

Note: Table column name and XML column or tag name should be same otherwise it will not insert into a table.

Below is a small demonstration of this:

First, Create a sample XML file:
Name of this file is Employee.xml and I have saved in my local drive.

Create a sample table:

Import XML Data into a table:

Check the table:

MySQL XML Import Data

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from

Leave a Reply

Be the First to Comment!

Notify of