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;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<Node> filterNodesByTag(NodeList nodes, String tagName) {
        ArrayList<Node> result = new ArrayList<>();
        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);
            if (node.getNodeName().equals(tagName)) {
                result.add(node);
            }
        }
        return result;
    }
}