Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Attr;

import org.w3c.dom.Node;

public class Main {

    public static Node addAttribute(Node pNode, String attrName, String attrValue) {
        Node attributeNode = null;
        try {
            Attr _attr = pNode.getOwnerDocument().createAttribute(attrName);
            _attr.setNodeValue(attrValue);

            attributeNode = pNode.getAttributes().setNamedItem(_attr);

        } catch (Exception e) {
            attributeNode = null;
        }

        return attributeNode;
    }
}