Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.Document;
import org.w3c.dom.Element;

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

public class Main {
    public static void setAllIdentityAttribute(Document document, String attributeValue) {
        NodeList propertyList = document.getElementsByTagName("Property");
        for (int i = 0; i < propertyList.getLength(); i++) {
            Node node = propertyList.item(i);
            for (int j = 0; j < node.getAttributes().getLength(); j++) {
                Node attribute = node.getAttributes().item(j);
                if (attribute.getNodeName().equals("name") && attribute.getNodeValue().equals(attributeValue)) {
                    Element element = (Element) node;
                    element.setAttribute("isIdentity", "true");
                }
            }
        }
    }
}