I have a xml file like this:
test.xml
Include this line ROWS IDENTIFIED BY '<plugin>'
. with that your query should look like
LOAD XML LOCAL INFILE "D:\\test.xml"
INTO TABLE mytable
ROWS IDENTIFIED BY '<plugin>';
Looks like your XML file formation is not correct and so even though 1 row gets inserted; all the values doesn't gets extracted (remains NULL
).
Do little changes as below
Create table structure
CREATE TABLE mytable (
plugin_name varchar(255),
title varchar(255),
description varchar(255),
`file` varchar(255),
`install` varchar(255),
hook varchar(255),
phrase varchar(255));
Change your XML file
<?xml version="1.0" encoding="utf-8" ?>
<plugin plugin_name="tree">
<title>Test</title>
<description>some description</description>
<file>test.tmp</file>
<install>![CDATA[
global $test;
]]</install>
<hook name="hookname">![CDATA[
global $local;
]]</hook>
<phrase key="category">![CDATA[Show categories]]</phrase>
</plugin>
Now if you use
LOAD XML LOCAL INFILE "D:\\test.xml"
INTO TABLE mytable
ROWS IDENTIFIED BY '<plugin>';
All data gets extracted fine
Beside the answer given above; I just wanted to add that the database fields character casing must be same as that of the XML field casing. Or else load XML wouldn't be able to import that specific column(s).