Java XML Element Set setText(Element element, String text)

Here you can find the source of setText(Element element, String text)

Description

set Text

License

Apache License

Declaration

public static void setText(Element element, String text) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.*;

public class Main {
    public static void setText(Element element, String text) {
        if (text == null || "".equals(text)) {
            // ignore null/empty string text
            return;
        }//  w  w  w.  j a  v  a 2 s  .c o m
        Text txt = element.getOwnerDocument().createTextNode(text);
        element.appendChild(txt);
    }
}

Related

  1. setProperty(Element element, BeanDefinitionBuilder bean, String name)
  2. setText(Element e, String text)
  3. setText(Element elem, String value)
  4. setText(Element element, String data)
  5. setText(Element element, String text)
  6. setText(Element element, String text)
  7. setTextContent(Element elem, String content)
  8. setTextContent(Element elem, String value)