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 {
    /**
     * Convenience method for setting a node's (attr or elem) text value.
     * 
     * @param node     The DOM node whose value needs to be changed.
     * @param newValue The value to set for node.
     */
    public static void setNodeValue(final Node node, final String newValue) {
        short nodeType = node.getNodeType();
        if (nodeType == Node.ATTRIBUTE_NODE) {
            node.setNodeValue(newValue);
        } else if (nodeType == Node.ELEMENT_NODE) {
            node.setTextContent(newValue);
        }
    }
}