Friday 5 August 2011

Adds the child element with the given text

  
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Utils {
  public static void addChildElement(Element element, String name, Object textValue) {
    Document document = element.getOwnerDocument();
    Element child = document.createElement(name);
    element.appendChild(child);
    if (textValue != null) {
      String text = textValue.toString();
      child.appendChild(document.createTextNode(text));
    }
  }
}

   
    
  

No comments:

Post a Comment