Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    /**
     * Gets <code>CDATASection</code> element for node.
     *
     * @param node node with text.
     * @return text, that contains the specified node.
     */
    public static String getNodeCDATASection(final Node node) {
        //        node.normalize();
        final NodeList list = node.getChildNodes();
        for (int i = 0, len = list.getLength(); i < len; i++) {
            final Node child = list.item(i);
            if (child.getNodeType() == Node.CDATA_SECTION_NODE)
                return child.getNodeValue();
        }
        return null;
    }
}