Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {

    public static Element getChild(Element parent, String name) {

        NodeList children = parent.getChildNodes();

        final int length = children.getLength();

        for (int index = 0; index < length; index++) {

            Node node = children.item(index);

            if (node.getNodeType() != Node.ELEMENT_NODE) {
                continue;
            }

            Element element = (Element) node;

            if (name.equalsIgnoreCase(element.getNodeName())) {
                return element;
            }
        }

        return null;
    }
}