LOAD XML INFILE formatting



I am very new to SQL so I hope this question makes sense. I looked online and couldn't find an answer anywhere so hopefully it isn't too trivial.


I am trying to import an xml file to create a county table. The xml file looks like this ...



<country name="Wales">
<county>Clwyd</county>
<county>Dyfed</county>
<county>Gwent</county>
<county>Gwynedd</county>
<county>Mid Glamorgan</county>
<county>Powys</county>
<county>South Glamorgan</county>
<county>West Glamorgan</county>
</country>
<country name="Northern Ireland">
<county>Antrim</county>
<county>Armagh</county>
<county>Down</county>
<county>Fermanagh</county>
<county>Londonderry</county>
<county>Tyrone</county>
</country


I am doing



LOAD XML LOCAL INFILE "file.xml" INTO TABLE county
ROWS IDENTIFIED BY '<county>'


but I am not sure how to grab the country name. (multiple counties will have the same country name).


Does anyone have suggestions, or know where I can look for documentation online? I did not find the MySQL documentation helpful.


Thanks!


No comments:

Post a Comment