What will we need often?

Most often used interfaces are:

Element

corresponds to the element in a logical document structure. It allows us to access name of the element, names of attributes, child nodes (including textual ones). Useful methods:

  • Node getParentNode() - returns the parent node

  • String getTextContent() - returns textual content of the element.

  • NodeList getElementsByTagName(String name) - returns the list of ancestors (child nodes and their ancestors) with the given name.

Node

super interface of Element, corresponds to the general node in a logical document structure, may contain element, textual node, comment, etc.

NodeList

a list of nodes (a result of calling getElementsByTagName for example). It offers the following methods for its processing:

  • int getLength() - returns the number of nodes in a list

  • Node item(int index) - returns the node at position index

Document

corresponds to the document node (its a parent of a root element)