Java tutorial
//package com.java2s; //License from project: Apache License import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static final void setNodeValue(Node node, String value) { if (value == null) value = ""; NodeList childNodes = node.getChildNodes(); int len = childNodes == null ? 0 : childNodes.getLength(); for (int i = 0; i < len; i++) { Node n = childNodes.item(i); n.setNodeValue(value); } } }