Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    /**
     * Fetch node using its name
     * 
     * @param node
     * @param name
     * @return
     */
    public static Node fetchByName(Node node, String name) {
        final NodeList list = node.getChildNodes();
        for (int i = 0; i < list.getLength(); i++) {
            final Node child = list.item(i);
            if (child.getNodeName().equals(name)) {
                return child;
            }
        }
        return null;
    }
}