Java XML Element Set setTextContent(Element node, String text)

Here you can find the source of setTextContent(Element node, String text)

Description

set Text Content

License

Open Source License

Declaration

public static void setTextContent(Element node, String text) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

public class Main {
    public static 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));
        }// w  ww  .  java2 s .co m
        node.appendChild(node.getOwnerDocument().createTextNode(text));
    }
}

Related

  1. setTextContent(Element elem, String value)
  2. setTextContent(Element element, String content)
  3. setTextContent(Element element, String content)
  4. setTextContent(Element element, String text)
  5. setTextContent(Element node, String text)
  6. setTextField(Element node, String subElement, String text)
  7. setTextValue(Element element, String text)
  8. setTextValue(Element element, String value)
  9. setToElements(Element rootElem, String name, Set s)