Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.Vector;

import org.w3c.dom.Element;

import org.w3c.dom.Node;

public class Main {
    public static Vector<Element> getChildElemsByName(final String name, final Node parent) {
        Vector<Element> v = new Vector<Element>();
        Element elem = null;
        for (Node childNode = parent.getFirstChild(); childNode != null; childNode = childNode.getNextSibling()) {
            if (childNode.getNodeType() == Node.ELEMENT_NODE) {
                if (childNode.getNodeName() == name) {
                    elem = (Element) childNode;
                    v.add(elem);
                }
            }
        }
        return v;
    }
}