Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {

    private static boolean hasEqualAttributes(Node arg0, Node arg) {

        NamedNodeMap map1 = arg0.getAttributes();
        NamedNodeMap map2 = arg.getAttributes();
        int len = map1.getLength();
        if (len != map2.getLength()) {
            return false;
        }

        for (int i = 0; i < len; i++) {
            Node n1 = map1.item(i);
            if (n1.getNodeName() != null) {
                Node n2 = map2.getNamedItem(n1.getNodeName());
                if (n2 == null) {
                    return false;
                } else if (!n1.getNodeValue().equals(n2.getNodeValue())) {
                    return false;
                }
            }
        }
        return true;
    }
}