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 final static Element subElement(Element superEle, String subName) {
        NodeList list = superEle.getChildNodes();
        if (list == null) {
            return null;
        }
        for (int i = 0; i < list.getLength(); i++) {
            Node node = list.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                if (node.getNodeName().equals(subName)) {
                    return (Element) node;
                }
            }
        }
        return null;
    }
}