Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.*;

public class Main {
    /** Helper method - Determines if a <I>Node</I> has any non-<I>CharacterData</I> nodes.
    This call is stricter than the <CODE>Node.hasChildNodes</CODE> call.
     */
    public static boolean hasNonCharacterChildren(Element pElement) {
        // Do the quick test.
        if (!pElement.hasChildNodes())
            return false;

        NodeList pNodeList = pElement.getChildNodes();
        int nLength = pNodeList.getLength();

        // Find a non-character data node.
        for (int i = 0; i < nLength; i++)
            if (!(pNodeList.item(i) instanceof CharacterData))
                return true;

        return false;
    }
}