Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Node;

public class Main {
    public static String getNodeText(Node node) {
        if (node == null)
            return null;
        StringBuffer buff = new StringBuffer();
        for (int c = 0; c < node.getChildNodes().getLength(); c++) {
            Node cn = node.getChildNodes().item(c);
            if (cn.getNodeType() == Node.TEXT_NODE || cn.getNodeType() == Node.CDATA_SECTION_NODE) {
                buff.append(cn.getNodeValue());
            }
        }
        return buff.toString().trim();

    }
}