Utils.java Source code

Java tutorial

Introduction

Here is the source code for Utils.java

Source

import org.w3c.dom.Node;

public class Utils {

    /**
     * Search for a named child of a given node
     * @param currentNode Starting point for our search
     * @param tagName Node name to look up
     * @return matching Node (null if none)
     */
    public static Node getChildSiblingByName(Node currentNode, String tagName) {
        Node node = currentNode.getFirstChild();

        while ((node != null) && (!node.getNodeName().equals(tagName))) {
            node = node.getNextSibling();
        }
        return node;
    }

}