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.Document;
import org.w3c.dom.Element;

public class Main {
    /**
     * Adds an attribute to the specified document element.
     * @param doc the document.
     * @param parent the parent element.
     * @param name the attribute name.
     * @param value the attribute value.
     * @return the attribute.
     */
    public static Attr addAttribute(final Document doc, final Element parent, final String name,
            final String value) {
        Attr attr = doc.createAttribute(name);
        attr.setNodeValue(value);
        parent.setAttributeNode(attr);
        return attr;
    }
}