Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat steps should be taken to convert my XML into Core Data objects?
    text
    copied!<p>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.</p> <p>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 <code>&lt;store-id&gt;</code>. I'm just trying to use a simple method to move them from XML to Core Data via some other data structure.</p> <p>XML sample:</p> <pre><code>&lt;stores&gt; &lt;store&gt; &lt;store-id&gt;1&lt;/store-id&gt; &lt;city&gt;Dublin&lt;/city&gt; &lt;phone&gt;011234567&lt;/phone&gt; &lt;phone&gt;011234566&lt;/phone&gt; &lt;owner&gt;Joe Bloggs&lt;/owner&gt; &lt;/store&gt; &lt;store&gt; &lt;store-id&gt;2&lt;/store-id&gt; &lt;city&gt;Cork&lt;/city&gt; &lt;phone&gt;019876543&lt;/phone&gt; &lt;phone&gt;019876542&lt;/phone&gt; &lt;owner&gt;Joe Bloggs&lt;/owner&gt; &lt;/store&gt; &lt;stores&gt; </code></pre> <p>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.</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload