Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    /**
     */
    public static String getComment(Element searchIn, int commentIndex) {
        NodeList list = searchIn.getChildNodes();
        int counter = 0;
        for (int i = 0; i < list.getLength(); i++) {
            Node n = list.item(i);
            if (n.getNodeType() == Node.COMMENT_NODE) {
                if (counter == commentIndex) {
                    return n.getTextContent();
                }
                counter++;
            }
        }
        return null;
    }
}