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

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

Description

Set or remove text for an element.

License

Open Source License

Parameter

Parameter Description
element a parameter
text the text to set or <code>null</code> to remove

Declaration

public static void setText(Element element, String text) 

Method Source Code

//package com.java2s;
/*//from  w  w w  .j  a v a 2 s  . co  m
  XMLUtils.java
    
  (c) 2010-2011 Edward Swartz
    
  All rights reserved. This program and the accompanying materials
  are made available under the terms of the Eclipse Public License v1.0
  which accompanies this distribution, and is available at
  http://www.eclipse.org/legal/epl-v10.html
 */

import org.w3c.dom.Element;

public class Main {
    /**
     * Set or remove text for an element.
     * @param element
     * @param text the text to set or <code>null</code> to remove
     */
    public static void setText(Element element, String text) {
        element.setTextContent(text);
    }
}

Related

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