Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Node;

public class Main {
    /**
     * get child node by name
     * 
     * @param parent
     * @param name
     * @return
     */
    public static Node getNodeByName(Node parent, String name) {
        for (int i = 0; i < parent.getChildNodes().getLength(); i++) {
            if (parent.getChildNodes().item(i).getNodeName().equals(name))
                return parent.getChildNodes().item(i);
        }

        return null;
    }
}