Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    /**
     * Returns the content of the first CDATA section node found under the specified node.
     * 
     * @param node
     *            the node.
     * @return the content of the first CDATA section node.
     */
    public static String getCDataSectionContent(Node node) {
        NodeList list = node.getChildNodes();
        for (int i = 0; i < list.getLength(); i++) {
            if (list.item(i).getNodeType() == Document.CDATA_SECTION_NODE) {
                return list.item(i).getNodeValue();
            }
        }
        return null;
    }
}