Java Utililty Methods XML Attribute Add

List of utility methods to do XML Attribute Add

Description

The list of methods to do XML Attribute Add are organized into topic(s).

Method

voidaddAllElementsWithAttrId(final List list, final Element element, final String namespace)
add All Elements With Attr Id
if (elementHasId(element, namespace)) {
    list.add(element);
NodeList children = element.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
    Node child = children.item(i);
    if (child instanceof Element == false) {
        continue;
...
voidaddArrayAnyTypeAttribute(Element element, Collection col)
Helper methods for adding an array.
addArrayAnyTypeAttribute(element, col.size());
voidaddArrayOffsetAttribute(Element element, int offset)
add Array Offset Attribute
element.setAttribute("SOAP-ENC:offset", new StringBuilder("[").append(offset).append("]").toString());
voidaddAttrDirect(Map values, Element el)
add Attr Direct
NamedNodeMap attrs = el.getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
    Node attr = attrs.item(i);
    values.put(attr.getNodeName(), attr.getNodeValue());
voidaddAttribute(Document doc, Element node, String name, String value)
add Attribute
Attr attribute = doc.createAttribute(name);
attribute.setValue(value);
node.getAttributes().setNamedItem(attribute);
voidaddAttribute(Document doc, Element node, String name, String value)
add Attribute
Attr attribute = doc.createAttribute(name);
attribute.setValue(value);
node.getAttributes().setNamedItem(attribute);
AttraddAttribute(Document doc, Element parent, String attribute, Object value)
add Attribute
Attr attr = doc.createAttribute(attribute);
attr.setValue(String.valueOf(value));
parent.setAttributeNode(attr);
return attr;
voidaddAttribute(Document doc, Node parentNode, String name, String content)
add Attribute
Attr attNode = doc.createAttribute(name);
attNode.setNodeValue(content);
parentNode.getAttributes().setNamedItem(attNode);
NodeaddAttribute(Document doc, org.w3c.dom.Element e, String index, String value)
add Attribute
e.setAttribute(index, value);
return e;
voidaddAttribute(Document doc, String name, Element e, String value)
add Attribute
Node attrNode = doc.createAttribute(name);
attrNode.setNodeValue(value);
NamedNodeMap attrs = e.getAttributes();
attrs.setNamedItem(attrNode);