Prior to MySQL 8.0.21, LOAD XML  did not support CDATA  sections in the source XML. (Bug #30753708, Bug #98199) 

The following clauses work essentially the same way for LOAD XML  as they do for LOAD DATA : 

• LOW_PRIORITY  or CONCURRENT 

• LOCAL 

• REPLACE  or IGNORE 

• CHARACTER SET 

• SET 

See Section 13.2.7, “LOAD DATA Statement” , for more information about these clauses. 

( field_name_or_user_var , ...)  is a list of one or more comma-separated XML fields or user variables. The name of a user variable used for this purpose must match the name of a field from the XML file, prefixed with @ . You can use field names to select only desired fields. User variables can be employed to store the corresponding field values for subsequent re-use. 

The IGNORE number  LINES  or IGNORE number  ROWS  clause causes the first number  rows in the XML file to be skipped. It is analogous to the LOAD DATA  statement’s IGNORE ... LINES  clause. 

Suppose that we have a table named person , created as shown here: 

USE test; CREATE TABLE person ( person_id INT NOT NULL PRIMARY KEY, fname VARCHAR(40) NULL, lname VARCHAR(40) NULL, created TIMESTAMP ); 

Suppose further that this table is initially empty. 

Now suppose that we have a simple XML file person.xml , whose contents are as shown here: 

<list> <person person_id="1" fname="Kapek" lname="Sainnouine"/> <person person_id="2" fname="Sajon" lname="Rondela"/> <person person_id="3"><fname>Likame</fname><lname>Örrtmons</lname></person> <person person_id="4"><fname>Slar</fname><lname>Manlanth</lname></person> <person><field name="person_id">5</field><field name="fname">Stoma</field> <field name="lname">Milu</field></person> <person><field name="person_id">6</field><field name="fname">Nirtam</field> <field name="lname">Sklöd</field></person> <person person_id="7"><fname>Sungam</fname><lname>Dulbåd</lname></person> <person person_id="8" fname="Sraref" lname="Encmelt"/> </list> 

Each of the permissible XML formats discussed previously is represented in this example file. 

To import the data in person.xml  into the person  table, you can use this statement: 

mysql> LOAD XML LOCAL INFILE ’person.xml’ -> INTO TABLE person -> ROWS IDENTIFIED BY ’<person>’; 

