TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: DOM-style parser or SAX parser?

2 点作者 expertcs超过 14 年前
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?

1 comment

1va超过 14 年前
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.