set Xml Attribute Value - Java XML

Java examples for XML:XML Attribute

Description

set Xml Attribute Value

Demo Code


//package com.java2s;

import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Main {
    public static final void setXmlAttributeValue(Document xml,
            Element elem, String name, String value) {
        Attr a = xml.createAttribute(name);
        a.setValue(value);//from w ww. j a v a2 s .co  m
        elem.getAttributes().setNamedItem(a);
    }
}

Related Tutorials