Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    public static String getValue(Element element) {
        NodeList l = element.getChildNodes();
        StringBuffer s = new StringBuffer();
        for (int i = 0; i < l.getLength(); i++) {
            switch (l.item(i).getNodeType()) {
            case Node.TEXT_NODE:
            case Node.CDATA_SECTION_NODE:
                s.append(l.item(i).getNodeValue());
            }
        }
        return s.toString();
    }
}