1

I am using NSURLConnection for loading the data and parse with nsxmlparser. Currently I let the whole data is loaded then I parse it but for improving the speed I would like to know how I can parse section of data which is received in didReceiveData delegate method. If I just move my parsing function in this method I would get error since when it breaks to different parts it doesn't have XML correct format or...

I would appreciate if some one could help me in anyway in case of improving the speed.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Finutv
  • 341
  • 1
  • 4
  • 17

3 Answers3

2

Here is apple sample code that should help you in improving performance. It parses xml data on the fly. You need to check in iTunesRSSParser and LibXMLParser if you want to use libXMl2 parser. and change according. There is also a way using NSXMLParser you can try that too. libxml2 would be a better way though.

Himanshu A Jadav
  • 2,286
  • 22
  • 34
  • +1 Agreed. LibXML2 seems to work fine. I'm not crazy about the sample code in that [XMLPerformance sample](http://developer.apple.com/library/ios/#samplecode/XMLPerformance/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008094), but the LibXML2 approach definitely avoids the problems with `NSXMLParser`. – Rob Dec 06 '12 at 05:31
0

Check: How To Choose The Best XML Parser for Your iPhone

It has code for 7 different ways of XML parsing and has them set up so you can test there efficiency it is worth looking at.

Anne
  • 26,765
  • 9
  • 65
  • 71
Michael Smith
  • 498
  • 2
  • 5
  • 15
0

In my opinion you will still need to download the whole file whether you will like to parse a part or the whole.

Memory wise and speed wise it will be best to save it locally and then parse the part that you want to parse. I haven't tried but I think it is possible for you to open the file and go to the part you want to parse.

Check this question it has an answer of what I am talking about

How to download a large file with the iPhone SDK and avoid memory usage issues?

Community
  • 1
  • 1
Metodij Zdravkin
  • 914
  • 1
  • 14
  • 23