Java XML Attribute from Element incrementAttributeValue(Node node, String attName)

Here you can find the source of incrementAttributeValue(Node node, String attName)

Description

increment Attribute Value

License

Open Source License

Declaration

public static void incrementAttributeValue(Node node, String attName) 

Method Source Code

//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);
    }//from w ww  .j ava  2  s.  com

    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);
    }
}

Related

  1. getValueAttributeUri(Element parent, String defaultBaseUri)
  2. getValueForAttribute(String attributeName, Node parentNode)
  3. getXMLAttribute(Element element, String attrName)
  4. getXMLAttributeValue(Element node, String attributeName)
  5. getXMLAttributeValueAsBoolean(Element node, String attributeName)
  6. isHTMLInputFileValueAttr(Node node, String attrName)