List of utility methods to do XML Element Set
void | setTextContent(Element element, String content) set Text Content Document document = element.getOwnerDocument(); element.appendChild(document.createTextNode(content)); |
void | setTextContent(Element element, String text) Removes any existing child content and inserts a text node with the given text Node child; while ((child = element.getFirstChild()) != null) { element.removeChild(child); if (text != null && text.length() > 0) { Text textNode = element.getOwnerDocument().createTextNode(text); element.appendChild(textNode); |
void | setTextContent(Element node, String text) This method is useful when DOM Level 3 "setTextContent" is not implemented final NodeList children = node.getChildNodes(); for (int i = (children.getLength() - 1); i > -1; i--) { node.removeChild(children.item(i)); node.appendChild(node.getOwnerDocument().createTextNode(text)); |
void | setTextContent(Element node, String text) set Text Content final NodeList children = node.getChildNodes(); for (int i = (children.getLength() - 1); i > -1; i--) { node.removeChild(children.item(i)); node.appendChild(node.getOwnerDocument().createTextNode(text)); |
Text | setTextField(Element node, String subElement, String text) set Text Field NodeList nl = node.getElementsByTagName(subElement); if (nl == null || nl.getLength() == 0) { if (text == null) return null; Document d = node.getOwnerDocument(); Element e = d.createElement(subElement); Text ans = d.createTextNode(text); e.appendChild(ans); ... |
void | setTextValue(Element element, String text) Replace the first text element of the given element with a new text element containing the given text or just create a new text element if there is none to replace. Node newTextNode = element.getOwnerDocument().createTextNode(text); NodeList childs = element.getChildNodes(); for (int i = 0; i < childs.getLength(); i++) { Node node = childs.item(i); if (Node.TEXT_NODE == node.getNodeType()) { element.replaceChild(newTextNode, node); return; element.appendChild(newTextNode); |
void | setTextValue(Element element, String value) set Text Value removeAllChildNodes(element);
if (value != null) {
Node text = element.getOwnerDocument().createTextNode(value);
element.appendChild(text);
|
void | setToElements(Element rootElem, String name, Set s) set To Elements iteratorToElements(rootElem, name, s.iterator()); |
void | setValue(Element element, String value) Set value to the specified element removeAllChilds(element); addValue(element, value); |