Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.Vector;

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

public class Main {
    /** Returns all child <code>Node</code>s with the given name stored in a
     *  <code>Vector</code>.
     *
     *  @param node The parent node to be searched for
     *  @param name The element name to search for
     *  @return <code>Vector</code> of found </code>Node</code>s
     */
    public static Vector getSubnodesByName(Node node, String name) {
        Vector retVal = null;
        NodeList nl = node.getChildNodes();
        if (nl != null && nl.getLength() != 0) {
            for (int i = 0; i < nl.getLength(); i++) {
                if (nl.item(i).getNodeName().equals(name)) {
                    if (retVal == null)
                        retVal = new Vector();
                    retVal.addElement(nl.item(i));
                }
            }
        }
        return retVal;
    }
}