Java XML Attribute Add addAttribute(Document document, Node node, String name, String value)

Here you can find the source of addAttribute(Document document, Node node, String name, String value)

Description

add Attribute

License

Open Source License

Declaration

public static void addAttribute(Document document, Node node, String name, String value) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2004-2010 Sunil Kamath (IcemanK). All rights reserved. This
 * program is made available under the terms of the Common Public License v1.0
 * which is available at http://www.eclipse.org/legal/cpl-v10.html
 * //from ww w .j  a  va  2s.  c o  m
 * Contributors: Sunil Kamath (IcemanK) - initial API and implementation
 *******************************************************************************/

import org.w3c.dom.*;

public class Main {
    public static void addAttribute(Document document, Node node, String name, String value) {
        if (value != null) {
            Attr attribute = document.createAttribute(name);
            attribute.setValue(value);
            node.getAttributes().setNamedItem(attribute);
        }
    }
}

Related

  1. addAttribute(Document doc, Element parent, String attribute, Object value)
  2. addAttribute(Document doc, Node parentNode, String name, String content)
  3. addAttribute(Document doc, org.w3c.dom.Element e, String index, String value)
  4. addAttribute(Document doc, String name, Element e, String value)
  5. addAttribute(Document document, Node node, String attName, String attValue)
  6. addAttribute(Document document, String AttribName, String attribValue, Element element)
  7. addAttribute(Document xmlDoc, Node node, String attrName, String attrValue)
  8. addAttribute(Element el, String name, String val)
  9. addAttribute(Element elem, String name, String value)