I have found examples of parsing xml to inserts. However these examples are really simple. They are usually just like this:
<person>
<name>Martin</name>
</person>
<person>
<name>John</name>
</person>
But I have XML similar to this - Where I need to have inserts into other tables for child elements.
<root>
<family>
<name>Smith</name>
<address>Some road 1</address>
<persons>
<person>
<name>Tina</name>
<hobbies>
<hobby>Some hobby 1</hobby>
<hobby>Some hobby 2</hobby>
</hobbies>
</person>
<person>
<name>Martin</name>
<hobbies>
<hobby>Some hobby 1</hobby>
<hobby>Some hobby 2</hobby>
</hobbies>
</person>
</persons>
</family>
<family>
<name>Lane</name>
<address>Some road 1</address>
<persons>
<person>
<name>Kevin</name>
<hobbies>
<hobby>Some hobby 1</hobby>
<hobby>Some hobby 2</hobby>
</hobbies>
</person>
<person>
<name>Julia</name>
<hobbies>
<hobby>Some hobby 1</hobby>
<hobby>Some hobby 2</hobby>
</hobbies>
</person>
</persons>
</family>
</root>
I need to iterate through this xml and first INSERT a row into table "Families" After that I return the ID for the family and use it as foreign key in the next INSERT for a person in the table "Persons" and same with the hobbies. I think you get the idea. And after a "Family" I need to do some update statements before moving on to the next family.
Could someone point me in the right direction ? Would be much appreciated.