Java XML Node Replace replaceText(Node node, String text)

Here you can find the source of replaceText(Node node, String text)

Description

replace Text

License

Open Source License

Declaration

public static void replaceText(Node node, String text) 

Method Source Code

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

import org.w3c.dom.Node;
import org.w3c.dom.Text;

public class Main {
    public static void replaceText(Node node, String text) {
        for (;;) {
            Node n = node.getFirstChild();
            if (n == null)
                break;
            node.removeChild(n);//from   ww w  .j a  v  a  2  s.  co  m
        }
        Text t = node.getOwnerDocument().createTextNode(text);
        node.appendChild(t);
    }
}

Related

  1. replaceComma(Node node)
  2. replaceNode(Node masterNode, Node oldNode, Node newNode)
  3. replaceNode(Node oldNode, Node newNode, Node source)
  4. replaceVariable(final Node node, final String sVar, final String sValue)
  5. replaceVariable(final Node node, final String var, final String valueString)
  6. replaceWith(Node currentNode, Node replacerNode)
  7. replaceWith(Node oldNode, Node newNode)