Importing from an XML source
If you have to import data from an XML source, APOC has your back again. Valid XML sources have a main advantage to already have been validated against an XSD schema (or a DTD).
Let's import some countries again, but this time by continent. Here is the XML, it is hand-written and voluntarily short, so do not feel offensed if you do not find your country in this list:
<?xml version="1.0"?> <earth> <continent name="Africa"> <country name="Morocco" money="Dinar"/> </continent> <continent name="Europe"> <country name="France" money="Euro"/> <country name="Germany" money="Euro"/> </continent> <continent name="Asia"> <country name="China" money="Yuan"/> <country name="Japan" money="Yen"/> </continent> </earth>
There are countries sharing a continent, and others sharing money. As usual, constraint creation takes place before importing:
CREATE CONSTRAINT ON (c:Continent...