开发者

What's the most efficient process for parsing XML and building a Core Data database?

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]></logo> 
<content>Lorem ipsum lorem ipsum</content>
</item>
<item id="2" category="jeans">
<name>Wrangler</name>
<logo><![CDATA[http://example.com/images/logos/wrangler.png]></logo> 
<content>Lorem ipsum lorem ipsum</content>
</item>开发者_Go百科;
</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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜