MySQL XML load behaving weird



I'm trying to load part of a XML file into my MySQL database on localhost. My table create query is:



CREATE TABLE IF NOT EXISTS `vacations`(
`type` varchar(255) NOT NULL,
`region` varchar(255) NOT NULL,
`startdate` date NOT NULL,
`enddate` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


The xml file is located here: http://ift.tt/1GTEyBe


I also copied the text on that page and saved it in a LOCAL xml file.


Now when I fill my table with the following query useing the ONLINE xml file



LOAD XML LOCAL INFILE 'http://ift.tt/1GTEyBe'
INTO TABLE vacations
ROWS IDENTIFIED BY '<vacation>'


My table will be filled with the following data:


('schoolvakanties', 'zuid', '2013-10-11', '2013-10-20'), ('schoolvakanties', 'heel Nederland', '2013-12-20', '2014-01-05'), ('schoolvakanties', 'zuid', '2014-02-14', '2014-02-23'), ('schoolvakanties', 'heel Nederland', '2014-04-25', '2014-05-05'), ('schoolvakanties', 'zuid', '2014-07-11', '2014-08-24'), ('schoolvakanties', 'zuid', '2014-10-17', '2014-10-26'), ('schoolvakanties', 'heel Nederland', '2014-12-19', '2015-01-04'), ('schoolvakanties', 'zuid', '2015-02-13', '2015-02-22'),


Note that this is not all of the data but only the first 8 rows


Now when I fill the table with data from the LOCAL xml file



LOAD XML LOCAL INFILE 'absolute_path_to_file\\thevacation.xml'
INTO TABLE vacations
ROWS IDENTIFIED BY '<vacation>'


I will get the following data in my table:


('\r\nHerfstvakantie\r\n', 'zuid', '2013-10-11', '2013-10-20'), ('\r\n', 'heel Nederland', '2013-12-20', '2014-01-05'), ('\r\n', 'zuid', '2014-02-14', '2014-02-23'), ('\r\n', 'heel Nederland', '2014-04-25', '2014-05-05'), ('\r\n', 'zuid', '2014-07-11', '2014-08-24'), ('\r\n', 'zuid', '2014-10-17', '2014-10-26'), ('\r\n', 'heel Nederland', '2014-12-19', '2015-01-04'), ('\r\n', 'zuid', '2015-02-13', '2015-02-22'), ('\r\n', 'heel Nederland', '2015-05-01', '2015-05-10'),


Note that this is not all of the data but only the first 8 rows


As you can see, when it takes the data from the LOCAL xml file it will take the I specified, the one inside the tags. But when I take the data from the ONLINE page it will just take the data from the first tag it sees.


Can anybody explain to me why it does this, and how I can solve this problem. Because I would rather take the data from that webpage, not from a local file.


Thank you


No comments:

Post a Comment