什么是 DOM?
DOM 是 W3C(World Wide Web Consortium)标准。
DOM 定义了访问诸如 XML 和 HTML 文档的标准:
"W3C 文档对象模型(DOM,全称 Document Object Model)是一个使程序和脚本有能力动态地访问和更新文档的内容、结构以及样式的平台和语言中立的接口。"
DOM 被分为 3 个不同的部分/级别:
- 核心 DOM - 用于任何结构化文档的标准模型
- XML DOM - 用于 XML 文档的标准模型
- HTML DOM - 用于 HTML 文档的标准模型
DOM 定义了所有文档元素的对象和属性,以及访问它们的方法(接口)。
SAX
(
Simple API for XML
) is an
event-driven
online algorithm
for
parsing
XML
documents, with an
API
developed by the XML-DEV mailing list.
[1]
SAX provides a mechanism for reading data from an XML document that is an alternative to that provided by the
Document Object Model
(DOM). Where the DOM operates on the document as a whole, SAX parsers operate on each piece of the XML document sequentially.
Definition[edit]
Unlike
DOM, there is no
formal specification for SAX. The
Java implementation of SAX is considered to be
normative.
[2] SAX processes documents state-independently, in contrast to
DOM which is used for state-dependent processing of XML documents.
[3] SAX parsers contrast with DOM-style parsers in a similar way
single-pass compilers contrast with
multi-pass ones.