Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Vector;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Text;

public class Main {
    public static synchronized String[] getElementValues(Element element) {
        if (element == null) {
            return null;
        }
        Vector childs = new Vector();
        for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) {
            if (node instanceof Text) {
                childs.add(node.getNodeValue());
            }
        }
        String[] values = new String[childs.size()];
        childs.toArray(values);
        return values;
    }
}