List of utility methods to do XML Element Text Set
void | setElementTextByAttr(Element modsroot, String nodename, String attrname, String attrvalue, String newValue) Sets text of element by attribute value (e.g. NodeList list = modsroot.getElementsByTagName(nodename); for (int i = 0; i < list.getLength(); i++) { Node node = (Node) list.item(i); NamedNodeMap attrs = node.getAttributes(); Attr attr = (Attr) attrs.getNamedItem(attrname); if (attr != null) { if (attr.getValue().equals(attrvalue)) { setTextValue(node, newValue); ... |
void | setElementTextValue(Element e, String text) set Element Text Value setElementTextValue(e, text, false); |
void | setElementValue(Element element, String val) Set the value of element Node node = element.getOwnerDocument().createTextNode(val); NodeList nl = element.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node nd = nl.item(i); if (nd.getNodeType() == Node.TEXT_NODE) { nd.setNodeValue(val); return; element.appendChild(node); |
void | setElementValue(Element element, String value) Appends the specified value as a text node to the element. Node child = element.getFirstChild(); if (value != null) { if (child == null) { child = element.getOwnerDocument().createTextNode(""); element.appendChild(child); child.setNodeValue(value); } else { ... |