DOM specification and implementation in Java (3)

zhaozj2021-02-17  57

2.NodeList interface

The NodeList interface provides an abstract definition of the node collection, which does not contain the definition of this node set. NodeList is used to represent a set of nodes with sequential relationships, such as sub-node sequences of a node. In addition, it also appears in a return value of some methods, such as GetNodeByName.

In the DOM, Nodelist's object is "Live", in other words, changes to the document will be directly reflected in the relevant Nodelist object. For example, if a Nodelist object is obtained via the DOM, the object contains a collection of all child nodes of a Element node, then, when the DOM is operated (add, delete, the child node in the node) via the DOM (add, delete, change the child node in the node) These changes will be automatically reflected in the Nodelist object without having the DOM application to do additional operations.

Each ITEM in NodeList can be accessed through an index that starts from 0.

Method Summary

int

GetLength () list node length

Node

Item (int index) Returns Item Node

3.NameDNodeMap interface

The object that implements the NameDNodeMap interface contains a collection of a set of nodes accessible through the name. However, NameDNodeMap is not inherited from Nodelist, and the node in the node set it contains is disorderly. Although these nodes can also be accessed by index, this is only provided an easy way to enumerate namedNodeMap, and do not indicate a node in the DOM specification to specify a node in NameDNodeMap.

NamedNodeMap represents a set of correspondence between a set of nodes and its unique names, which is mainly used on the indication of the attribute node. As with nodelist, in the DOM, the NameDNodeMap object is also "Live".

Method Summary

int

GetLength () gets the number of nodes in the mapping

Node

GetNamedItem (java.lang.string name) get a node through the only name

Node

GetNamedItemns (java.lang.string namespaceuri, java.lang.string localname) Get unique nodes through the URI of the local name and namespace

Node

Item (int index) gets the Idex node in the image

Node

RemovenamedItem (Java.lang.String Name) Delete a node via a unique name

Node

RemoveNamedItemns (java.lang.string namespaceuri, java.lang.string localname) Remove unique nodes through local name and namespace

Node

SetNameDItem (Node Arg) Add a node with arg

Node

SetNamedItemns (Node Arg) adds a node with the NRI and local names with namespaces

Advanced interface:

Interface summary

Attr

Attributes representing element objects

CDASECTION

The CDATA item in the DTD or mode is used to "escape" that does not want to be interpreted as tagged. In DTD, use

Characterdata

In DOM, provide a set of methods and properties operators data

Comment

Represents the contents of the comment element

Document

Document interface describes the entire HTML or XML document

Documentfragment

DocumentFragment is a lightweight object, he can create a new document segment, then insert the entire piece into a document DocumentType

Type declaration or mode information containing documents

DomIMPlementation

This object allows access to the application related to the application and independent of any specific document object model instance

ELEMENT

On behalf of the elements in the HTML / XML document, common elements are: Element, Attr, Text

Entity

Representatives of analytical or unresolved entities in the DTD in the DTD

EntityReference

Representing the entity reference node in the XML document, if the XML processor expands the entity reference when building a structural model, the entity reference object may not occur.

NOTATION

Representatives in DTD or mode with elements declaration representation

Processinginstructiontruction

The representative is embedded through the XML command through '>', which provides a method of saving information related to the processor in an XML document

TEXT

Text content representative element node or attribute node

Important node type

Several important node types derived from Node have Document Element, Attribute, Text:

Document is the root of the DOM tree, which represents a complete XML document. It will have some own child nodes, at least there should be a sub-node of a document element. This node type is Element, which is the outermost root element of the XML file. In addition, he may have DocumentType (unique), processinginstruction, comment As a child node.

ELEMENT represents an XML element, which is the most common node, which makes it into a subtree of DOM it is root. He can have a Element child node, as well as Attribut, Text, Processinginstruction, CDASECTION, Comment child node.

Attribute is the properties of the XML element, and its parent node is inevitably Element, its child node has Text and Entityreference;

Text represents the text content of the element node or attribute node.

转载请注明原文地址:https://www.9cbs.com/read-29560.html

New Post(0)