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 element, String fieldName) {
        if ((element == null) || (fieldName == null) || fieldName.equals("")) {
            return null;
        }
        NodeList children = element.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node child = children.item(i);
            if ((child instanceof Element) && child.getNodeName().equals(fieldName)) {
                return (Element) child;
            }
        }
        return null;
    }
}