Java XML Attribute Create createAttribute(String sName, String sValue, Node nParent)

Here you can find the source of createAttribute(String sName, String sValue, Node nParent)

Description

This method creates an attribute with the given name and value.

License

Apache License

Parameter

Parameter Description
sName The name of the attribute.
sValue The value of the atrtibute.
nParent The parent node.

Declaration

public static void createAttribute(String sName, String sValue, Node nParent) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class Main {
    /**/*from  ww w  .j  a  va 2 s. c om*/
     * This method creates an attribute with the given name and value.
     *
     * @param  sName    The name of the attribute.
     * @param  sValue   The value of the atrtibute.
     * @param  nParent  The parent node.
     */
    public static void createAttribute(String sName, String sValue, Node nParent) {
        if ((nParent != null) && (nParent instanceof Element)) {
            Element eParent = (Element) nParent;
            eParent.setAttribute(sName, sValue);
        }
    }
}

Related

  1. createAttr(Element parent, String name, Object value)
  2. createAttr(String attrName, String attrValue, Document document)
  3. createAttribute(Document doc, String friendlyName, String samlNS, String samlPrefix, QName attrKey)
  4. createAttribute(Document doc, String nodeName, Map map)
  5. createAttribute(Document document, String name, String value)
  6. createAttributeTable(Element e)
  7. createFillAttributeGraphics(Document d, boolean showColor, boolean showGradientColor, boolean showGradientRotation, boolean showImage)
  8. createFontAttributeGraphics(Document d, boolean showFamily, boolean showStyle, boolean showWeight, boolean showSize, boolean showDecoration, boolean showAlign, boolean showRotation)
  9. mapifyAttrs(Node node, Map overwrite)