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 {
    public static Node getChildNodebyName(Node parentNode, String nameOfChildToFind) {
        NodeList childNodes = parentNode.getChildNodes();
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node currentChildNode = childNodes.item(i);
            String childName = currentChildNode.getLocalName();
            if (childName != null)
                if (childName.equals(nameOfChildToFind))
                    return currentChildNode;
        }
        return null;
    }
}