- All Known Implementing Classes:
DOMDocument
,DOMElement
,HTMLDocument
,HTMLElement
ParentNode
interface.-
Field Summary
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
-
Method Summary
Modifier and TypeMethodDescriptionCreates a new iterator descending over the child nodes, starting from the last child node.Creates a new iterator over the child elements.elementIterator
(String name) Creates a new iterator over the child elements of the given tagname.elementIteratorNS
(String namespaceURI, String localName) Creates a new iterator over the child elements of the given namespaceURI and localName.int
Gets the number of child nodes of type Element that this parent node has.Gets aDOMNodeList
containing all the children of this parent node.Gets the live ElementList containing all nodes of type Element that are children of this ParentNode.getElementsByClassName
(String names) Gives a liveElementList
containing all the descending elements which have all of the given class names under this reference node.getElementsByTagName
(String name) Gives anElementList
of all the elements descending from this context node that have the given tag name, in document order.getElementsByTagNameNS
(String namespaceURI, String localName) Gives anElementList
of all the elements descending from this context node that have the given local name and namespace URI, in document order.Gets the Element that is the first child of this ParentNode.Gets the Element that is the last child of this ParentNode.iterator()
Creates a new iterator over the child nodes.iterator
(int whatToShow, NodeFilter filter) Creates a new iterator over the child nodes.iterator
(NodeFilter filter) Creates a new iterator over the child nodes.Creates a new iterator over the child nodes.Creates a new list iterator over the child nodes.prependChild
(Node newChild) Inserts the nodenewChild
at the beginning of the list of children of this node.querySelectorAll
(String selectors) Gets a staticElementList
of the descendant elements that match any of the specified list of selectors.typeIterator
(short typeToShow) Creates a new iterator over the child nodes.Methods inherited from interface io.sf.carte.doc.dom.DOMNode
appendChild, getFirstChild, getLastChild, getNextSibling, getOwnerDocument, getParentNode, getPreviousSibling, hasChildNodes, insertBefore, removeChild, replaceChild
Methods inherited from interface org.w3c.dom.Node
cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getFeature, getLocalName, getNamespaceURI, getNodeName, getNodeType, getNodeValue, getPrefix, getTextContent, getUserData, hasAttributes, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, setNodeValue, setPrefix, setTextContent, setUserData
-
Method Details
-
getChildNodes
DOMNodeList getChildNodes()Gets aDOMNodeList
containing all the children of this parent node.- Specified by:
getChildNodes
in interfaceDOMNode
- Specified by:
getChildNodes
in interfaceNode
- Returns:
- the list of child nodes, empty if there are no children.
-
getChildren
ElementList getChildren()Gets the live ElementList containing all nodes of type Element that are children of this ParentNode.- Returns:
- the ElementList containing all nodes of type Element that are children of this ParentNode.
-
getFirstElementChild
DOMElement getFirstElementChild()Gets the Element that is the first child of this ParentNode.- Returns:
- the Element that is the first child of this ParentNode, or
null
if there is none.
-
getLastElementChild
DOMElement getLastElementChild()Gets the Element that is the last child of this ParentNode.- Returns:
- the Element that is the last child of this ParentNode, or
null
if there is none.
-
getChildElementCount
int getChildElementCount()Gets the number of child nodes of type Element that this parent node has.- Returns:
- the number of child nodes of type Element that this parent node has.
-
prependChild
Inserts the nodenewChild
at the beginning of the list of children of this node. If thenewChild
is already in the tree, it is first removed.- Parameters:
newChild
- the node to prepend. If it is aDocumentFragment
object, the entire contents of the document fragment are moved into the child list of this node.- Returns:
- the prepended node.
- Throws:
DOMException
- HIERARCHY_REQUEST_ERR: raised if this node is of a type that does not allow children of the type of thenewChild
node, or if the node to prepend is one of this node's ancestors or this node itself, or if this node is of typeDocument
and the DOM application attempts to prepend a secondDocumentType
orElement
node.
WRONG_DOCUMENT_ERR: ifnewChild
was created from a different document than the one that created this node.
NOT_SUPPORTED_ERR: if this implementation does not support children of the type ofnewChild
at this node.
-
iterator
Creates a new iterator over the child nodes.- Returns:
- an iterator over the child nodes.
-
descendingIterator
Creates a new iterator descending over the child nodes, starting from the last child node.- Returns:
- an iterator descending over the child nodes.
-
iterator
Creates a new iterator over the child nodes.It only iterates over types set in the whatToShow bit field.
Example:
BitSet mask = new BitSet(32); mask.set(Node.ELEMENT_NODE); Iterator
it = node.iterator(mask); - Parameters:
whatToShow
- a bit set.- Returns:
- an iterator over the child nodes.
-
iterator
Creates a new iterator over the child nodes.It only iterates over nodes accepted by the filter.
- Parameters:
filter
- a filter, seeNodeFilter
.- Returns:
- an iterator over the child nodes.
-
iterator
Creates a new iterator over the child nodes.It only iterates over types set in the whatToShow mask that satisfy the custom
NodeFilter
.Example:
Iterator
it = node.iterator(NodeFilter.SHOW_ELEMENT, null); - Parameters:
whatToShow
- the bit field mask to apply to the node types, seeNodeFilter
. Do not confuse this argument with theshort
argument of thetypeIterator(short)
method.filter
- the filter to use in the iteration. ifnull
, only thewhatToShow
mask filter is applied.- Returns:
- an iterator over the child nodes.
-
typeIterator
Creates a new iterator over the child nodes.Do not confuse the
typeToShow
argument with theint
argument of theiterator(int, NodeFilter)
method, which is a bit field.- Parameters:
typeToShow
- the node type to show (fromNode.getNodeType()
).- Returns:
- an iterator over the child nodes.
-
elementIterator
Iterator<DOMElement> elementIterator()Creates a new iterator over the child elements.- Returns:
- an iterator over the child elements.
-
elementIterator
Creates a new iterator over the child elements of the given tagname.- Parameters:
name
- The tag name of the child elements to match on.- Returns:
- an iterator over the child elements.
- Throws:
DOMException
- INVALID_CHARACTER_ERR if thename
ifnull
or the empty string.
-
elementIteratorNS
Creates a new iterator over the child elements of the given namespaceURI and localName.- Parameters:
namespaceURI
- the namespace URI of the elements to match on.localName
- The local name of the elements to match on.- Returns:
- an iterator over the child elements.
-
listIterator
NodeListIterator listIterator()Creates a new list iterator over the child nodes.- Returns:
- a list iterator over the child nodes.
-
querySelectorAll
Gets a staticElementList
of the descendant elements that match any of the specified list of selectors.Unlike methods like
getElementsByTagName(String)
orgetElementsByClassName(String)
, this is not a live list but a static one, representing the state of the document when the method was called. If no elements match, the list shall be empty.- Parameters:
selectors
- a comma-separated list of selectors.- Returns:
- an
ElementList
with the elements that match any of the specified group of selectors.
-
getElementsByTagName
Gives anElementList
of all the elements descending from this context node that have the given tag name, in document order.The list is a live collection, and changes to the document made after calling this method are reflected in the
ElementList
.The most efficient way to browse the returned list is to iterate it.
- Parameters:
name
- The tag name of the elements to match on. The special value "*
" matches all tag names.- Returns:
- the
ElementList
object containing all the matched elements.
-
getElementsByTagNameNS
Gives anElementList
of all the elements descending from this context node that have the given local name and namespace URI, in document order.The list is a live collection, and changes to the document made after calling this method are reflected in the
ElementList
.The most efficient way to browse the returned list is to iterate it.
- Parameters:
namespaceURI
- the namespace URI of the elements to match on. The special value "*
" matches all namespaces.localName
- The local name of the elements to match on. The special value "*
" matches all local names.- Returns:
- the
ElementList
object containing all the matched elements.
-
getElementsByClassName
Gives a liveElementList
containing all the descending elements which have all of the given class names under this reference node.The list is a live collection, and changes to the document made after calling this method are reflected in the
ElementList
.The most efficient way to browse the returned list is to iterate it.
- Parameters:
names
- the names of the classes, separated by whitespace.- Returns:
- the live
ElementList
containing all the descending elements which have all of the given class names under this reference node.
-