How i can import a custom XML file into a MySQL?
My XML :
<ObjectList>
<Section Index="0" Name="MichaelCat">
<Item Index="0" Slot="0" FirstNmae="Example1" LastName="Example2" Age="30" />
<Item Index="1" Slot="0" FirstNmae="Example1.2" LastName="Example2.1" Age="30" />
</Section>
<Section Index="1" Name="MichaelCat2">
<Item Index="0" Slot="0" FirstNmae="Example1" LastName="Example2" Age="30" />
<Item Index="1" Slot="0" FirstNmae="Example1.2" LastName="Example2.1" Age="30" />
</Section>
</ObjectList>
My DB Schema:
SectionName | Section | Index | Slot | FIrstName | LastName | Age
In SectionName need to be inserted Section->Name
In Section need to be inserted Section->Index
In Index need to be inserted Section->Item->Index
In Slot need to be inserted Section->Item->Slot
etc..
In MSSQL i use:
DECLARE @input XML = 'MY XML file'
select
Name = XCol.value('../@Index','varchar(25)'),
Cat = XCol.value('../@Name','varchar(25)'),
[Index] = XCol.value('@Index','varchar(25)'),
Slot = XCol.value('@Slot','varchar(25)')
from
@input.nodes('/ItemList/Section/Item') AS test(XCol)
Thank you very much