Dom 简明教程
XML DOM - Overview
文档对象模型 (DOM) 是一项 W3C 标准。它定义了一个用于访问如 HTML 和 XML 之类的文档的标准。
The *D*ocument *O*bject *M*odel (DOM) is a W3C standard. It defines a standard for accessing documents like HTML and XML.
W3C 给出的 DOM 定义如下:
Definition of DOM as put by the W3C is −
DOM 定义了用于访问所有 XML 元素的对象、属性和方法(接口)。它分为 3 个不同的部分/等级:
DOM defines the objects and properties and methods (interface) to access all XML elements. It is separated into 3 different parts / levels −
-
Core DOM − standard model for any structured document
-
XML DOM − standard model for XML documents
-
HTML DOM − standard model for HTML documents
XML DOM 是 XML 的标准对象模型。XML 文档有层次分明的信息单元,称为节点;DOM 是一个标准编程接口,用于描述这些节点及其之间的关系。
XML DOM is a standard object model for XML. XML documents have a hierarchy of informational units called nodes; DOM is a standard programming interface of describing those nodes and the relationships between them.
此外,XML DOM 还提供了一个 API,允许开发人员在树上的任何一点添加、编辑、移动或删除节点,以便创建应用程序。
As XML DOM also provides an API that allows a developer to add, edit, move or remove nodes at any point on the tree in order to create an application.
以下是 DOM 结构的示意图。该图描绘了解析器如何通过遍历每个节点将一个 XML 文档计算为一个 DOM 结构。
Following is the diagram for the DOM structure. The diagram depicts that parser evaluates an XML document as a DOM structure by traversing through each node.
Advantages of XML DOM
以下是 XML DOM 的优点:
The following are the advantages of XML DOM.
-
XML DOM is language and platform independent.
-
XML DOM is traversable - Information in XML DOM is organized in a hierarchy which allows developer to navigate around the hierarchy looking for specific information.
-
XML DOM is modifiable - It is dynamic in nature providing the developer a scope to add, edit, move or remove nodes at any point on the tree.