views:

38

answers:

1

Let's say I'm getting I'm receiving XML files from some web service, like these two examples..

<news>
<item id="123" created="10/09/10" expires="07/07/10" modified="10/09/10">
<title>Xiabo receives Nobel></title>
<content>Lorem ipsum lorem ipsum</content>
</item>
</news>

.

<products>
<item id="1" category="shoes">
<name>Nike Air</name>
<logo><![CDATA[http://example.com/images/logos/nikeair.png]&gt;&lt;/logo&gt; 
<content>Lorem ipsum lorem ipsum</content>
</item>
<item id="2" category="jeans">
<name>Wrangler</name>
<logo><![CDATA[http://example.com/images/logos/wrangler.png]&gt;&lt;/logo&gt; 
<content>Lorem ipsum lorem ipsum</content>
</item>
</products>

How would I parse these XML files and then add them to Core Data, so that next time I load the app the data will be there without reloading the XML.

Sorry my question is so vague, I'm just trying to get my head around it.

+1  A: 

If you have any control over the web service, you should change XML format to JSON. Obj-C can digest JSON very efficiently. XML parsing(be it with xmllib or NSXMLParser) is not very efficient. My empirical analyses shows that NSXMLParser is faster at the expense of flexibility.

bioffe
Unfortunately, I have no such control.
cannyboy
Simplest(not the best) solution is to dump this xml as text file or blob and parse it into business objects with the same code you'd use to parse network datastream.
bioffe