Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

public class Main {
    public static Element getFirstChildElementByTagName(Element element, String name) {
        boolean found = false;
        Element result = null;
        NodeList nl = element.getChildNodes();
        for (int i = 0; i < nl.getLength() && !found; i++) {
            if (nl.item(i) instanceof Element) {
                if (name.equals(nl.item(i).getNodeName())) {
                    result = (Element) nl.item(i);
                    found = true;
                }
            }

        }
        return result;
    }
}