Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/********************************************************************
 * Copyright (c) 1999 The Bean Factory, LLC.
 * All Rights Reserved.
 *
 * The Bean Factory, LLC. makes no representations or
 * warranties about the suitability of the software, either express
 * or implied, including but not limited to the implied warranties of
 * merchantableness, fitness for a particular purpose, or
 * non-infringement. The Bean Factory, LLC. shall not be
 * liable for any damages suffered by licensee as a result of using,
 * modifying or distributing this software or its derivatives.
 *
 *******************************************************************/

import org.w3c.dom.*;

public class Main {
    /**
     For testing purpose, it print out Node list
        
     @param     rows    a Nodelist
     */
    public static void printNodeTypes(NodeList rows) {
        System.out.println("\tenumerating NodeList (of Elements):");
        System.out.println("\tClass\tNT\tNV");
        //iterate a given Node list
        for (int ri = 0; ri < rows.getLength(); ri++) {
            Node n = (Node) rows.item(ri);
            if (n instanceof Element) {
                System.out.print("\tElement");
            } else
                System.out.print("\tNode");

            //print out Node type and Node value
            System.out.println("\t" + n.getNodeType() + "\t" + n.getNodeValue());
        }
        System.out.println();
    }
}