Hi all, I have an XML file which contains lists of stores, a simplified version is below. What I would like help with is some high-level ideas on the simplest ways to move this data into objects for storage in Core Data. I see suggestions around key-value pairs but as you can see in my example below, I have child elements with the same name/key and there can be an arbitrary number of these for each store element.
I intend to store these objects within the app for future use (they will be annotations on a map). So, each duplicate field needs to be stored, one of them will not suffice. I know how to model it in Core Data I believe, I'll have a phone-number entity and a store entity and will just relate the two based on <store-id>
. I'm just trying to use a simple method to move them from XML to Core Data via some other data structure.
XML sample:
<stores>
<store>
<store-id>1</store-id>
<city>Dublin</city>
<phone>011234567</phone>
<phone>011234566</phone>
<owner>Joe Bloggs</owner>
</store>
<store>
<store-id>2</store-id>
<city>Cork</city>
<phone>019876543</phone>
<phone>019876542</phone>
<owner>Joe Bloggs</owner>
</store>
<stores>
If key-value pairs are the way to go, please point me to a method where I can account for the duplicate elements. If there's another way, I'm all ears.
Thanks