We are building web services (APIs) which can be used within iPhone apps for data synchronization. I was wondering which one is generally better: SAX parsing or DOM-style parsing in the iPhone app. There is no dependency and we can chose any but I am confused whether to chose the easy one (SAX), as it is sequential and not a memory hog like DOM. Any particular reasons to chose DOM if you dont need to?
Here's how I'd look at it: Is the kind of processing you are doing more like the kind of thing you'd do in a text editor (where you need to move around a lot in the source file) or the kind of thing you'd do with "cat" or "tail" (where the last couple of lines is all the context you need).<p>* SAX is stream based. This is like "cat" or "tail" on a Linux system, there is no history besides what you yourself put together. If you don't need to walk up and down the tree (much) then this is by far more space and time efficient.<p>* DOM is tree based. This parses the whole document into memory and gives you an API for walking up and down it. If you need to jump around in the document, this may be the way to go, but note that parsing and storing the full document takes time and memory.