Reputation: 11855
My Iphone communicates with my SOAP web service.
I have a questionnaire in my XML, which includes questions, their answers, and choices of some UI information..etc. So when the user enters a value for a set of questions using the IPhone and sends them back again to the Web service, the Service will add new unanswered questions to that XML.
So a conversation with the Web service starts with an empty XML and builds up to 200-300Kb of XML as the user answers the questions and receives new ones. Since it is a stateless Web Service, all the information will be kept in the XML.
Practically, I only need to find and parse the latest questions from the response XML, which should be good with a SAX parser, and modify only that part of the XML while adding the new answer and sending back again via the Web service the modified XML. BUT the user also should be able to click "Back". So that means I have to hold that XML in memory(200-300KB) and parse when necessary as the user clicks back and next.
My question is which approach is better:
1-Get the XML, parse it totally into objects with the DOM, release XML from memory and work only with the objects as the user clicks back and next. Then when it comes to sending it back, assemble a new XML message from scratch with my objects. Also this approach seems to reduce the clicking time
2-Use the SAX parser and only parse when I need to as the user clicks back and next. But then I have to hold all the XML in the memory. I do not know if Iphone can handle that, and back-next actions should take longer since I parse every time. But the good side is that I don't need to re-assemble an XML from objects again when I am done.
I think the second approach is better, what do you think? And which parser is good for this job?
Upvotes: 2
Views: 1286
Reputation: 12979
Personally I prefer DOM XML parsers due to their ease of use and the ability to separate parsing/creating logic from the rest of the code. It seems that your application would be best suited to use a DOM parser because you said so yourself that sometimes you only need certain parts of the XML, not the entire document. SAX parsers do not support random read access.
Upvotes: 1
Reputation: 8267
read the following article and you will find the best solution for you http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project
I would go with NSXMLDocument nevertheless.
Upvotes: 0