Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
// modify it under the terms of the GNU General Public License

import org.w3c.dom.Element;

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

public class Main {
    public static String getTextContents(Element e) {
        if (!e.hasChildNodes())
            return null;

        StringBuffer buf = new StringBuffer();
        NodeList list = e.getChildNodes();
        int len = list.getLength();
        String text;
        for (int i = 0; i < len; i++) {
            text = ((Node) list.item(i)).getNodeValue();
            if (text != null)
                buf.append(text);
        }
        return buf.toString();
    }
}