Java Utililty Methods XML Node Previous

List of utility methods to do XML Node Previous

Description

The list of methods to do XML Node Previous are organized into topic(s).

Method

NodegetPreviousElementNode(Node node)
get Previous Element Node
Node previous = node.getPreviousSibling();
while (!(previous instanceof Element) && previous != null) {
    previous = previous.getPreviousSibling();
if (previous instanceof Text) {
    return null;
return previous;
...
NodegetPreviousNodeByName(Node currentNode, String tagName)
Search up the tree for a given node
Node node = currentNode.getParentNode();
while ((node != null) && (!node.getNodeName().equals(tagName))) {
    node = node.getParentNode();
return node;
NodegetPreviousTypedNode(Node node, short nodeType)
get Previous Typed Node
node = node.getPreviousSibling();
while (node != null && node.getNodeType() != nodeType) {
    node = node.getPreviousSibling();
return node;
NodegetPreviousTypedNode(Node node, short nodeType)
get Previous Typed Node
node = node.getPreviousSibling();
while (node != null && node.getNodeType() != nodeType) {
    node = node.getPreviousSibling();
return node;
NodegetPreviousTypedNode(Node node, short nodeType)
get Previous Typed Node
node = node.getPreviousSibling();
while (node != null && node.getNodeType() != nodeType) {
    node = node.getPreviousSibling();
return node;