List of utility methods to do XML Attribute Add
void | addAttribute(final Node node, final Attr attribute) add Attribute if (node != null) {
node.getAttributes().setNamedItem(attribute);
|
Attr | addAttribute(Node parent, String name, String value) add Attribute if (value == null) return null; Attr node = parent.getOwnerDocument().createAttribute(name); try { node.setValue(value); parent.getAttributes().setNamedItem(node); } catch (Exception e) { System.out.println("Problem rewriting " + parent.getNodeName() + "." + name + "='" + node.getValue() ... |
Node | addAttribute(Node pNode, String attrName, String attrValue) add Attribute Node attributeNode = null; try { Attr _attr = pNode.getOwnerDocument().createAttribute(attrName); _attr.setNodeValue(attrValue); attributeNode = pNode.getAttributes().setNamedItem(_attr); } catch (Exception e) { attributeNode = null; return attributeNode; |
Element | addAttributes(Element element, String[][] attributes) add Attributes for (String[] attr : attributes) { element.setAttribute(attr[0], attr[1]); return element; |
String | addAttributeToXPathExpression(Node nodeAttr, String xpathExpression, String and) add Attribute To X Path Expression String value = nodeAttr.getNodeValue(); xpathExpression = xpathExpression + and + "@" + nodeAttr.getNodeName() + "='" + value + "'"; return xpathExpression; |
Node | addDomAttr(Document doc, String tagName, String tagNamespaceURI, String attrName, String attrValue) Adds the attribute to each node in the Document with the given name. Document newDoc = null; try { System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); newDoc = db.newDocument(); ... |
void | addDoubleAttributeAsInteger(Element element, String attName, double value) add Double Attribute As Integer element.setAttribute(attName, Long.toString(Math.round(value))); |
Element | addElement(Node parent, String name, Attr[] attrs) add Element Element element; if (parent instanceof Document) { element = ((Document) parent).createElement(name); } else { element = parent.getOwnerDocument().createElement(name); if (attrs != null && attrs.length > 0) { for (Attr attr : attrs) { ... |
Node | addElementAndAttributes(Node parent, String name, String[] atts) add Element And Attributes Node n = addElement(parent, name); for (int i = 0; i < atts.length; i += 2) addAttribute(n, atts[i], atts[i + 1]); return n; |
void | addNewElementWithAttribute(Node node, String elementName, String elementValue, String attrName, String attrValue) add New Element With Attribute Document xmlDoc = node.getOwnerDocument(); addNewElementWithAttribute(xmlDoc, node, elementName, elementValue, attrName, attrValue); |