Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Node;

public class Main {
    public static void incrementAttributeValue(Node node, String attName) {
        incrementAttributeValue(node, attName, 1);
    }

    public static void incrementAttributeValue(Node node, String attName, String attValue) {
        try {
            incrementAttributeValue(node, attName, Integer.decode(attValue));
        } catch (NumberFormatException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public static void incrementAttributeValue(Node node, String attName, int value) {
        Node attr = node.getAttributes().getNamedItem(attName);
        String attValue = String.valueOf(Integer.parseInt(attr.getNodeValue()) + value);
        attr.setNodeValue(attValue);
    }
}