Java XML Node Next getNextNode(Node current)

Here you can find the source of getNextNode(Node current)

Description

get Next Node

License

Open Source License

Declaration

public static Node getNextNode(Node current) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Node;

public class Main {
    public static Node getNextNode(Node current) {
        if (current == null) {
            System.out.println("NODE IS NULL");
            return null;
        }//from ww  w .  ja  v  a2 s  . c o  m
        boolean found = false;
        boolean childVisited = false;
        while (found != true) {
            if (current.hasChildNodes() && childVisited == false) {
                current = current.getFirstChild();
                found = true;
            } else {
                if (current.getNextSibling() != null) {
                    current = current.getNextSibling();
                    found = true;
                    childVisited = false;
                } else {
                    if (current.getParentNode() != null)
                        current = current.getParentNode();
                    else {
                        return null;
                    }
                    childVisited = true;
                }
            }
        }
        return current;
    }
}

Related

  1. getNextElement(Node node)
  2. getNextElement(Node node)
  3. getNextElement(Node node)
  4. getNextElementNode(Node node)
  5. getNextElementNode(Node node)
  6. getNextNodeByName(Node currentNode, String tagName)
  7. getNextTypedNode(Node node, short nodeType)
  8. getNextTypedNode(Node node, short nodeType)
  9. getNextTypedNode(Node node, short nodeType)