Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import org.w3c.dom.*;

public class Main {
    public static Element findFirstChild(Element elem, String tagName) {
        int i = findFirstChildIndex(elem, tagName);
        if (i >= 0) {
            return (Element) elem.getChildNodes().item(i);
        } else {
            return null;
        }
    }

    public static int findFirstChildIndex(Element elem, String tagName) {
        NodeList nl = elem.getChildNodes();
        for (int i = 0; i < nl.getLength(); ++i) {
            if (nl.item(i).getNodeName().equals(tagName))
                return i;
        }
        return -1;
    }
}