/***** Code de MesExemples.com *******/
import org.w3c.dom.Document;import org.w3c.dom.Element;public class Utils { /** * Add an entity to a specified Element. * (eg DomUtils.addEntity(element, "nbsp");
) * @param element the containing element * @param entity the entity to add */ public static void addEntity(Element element, String entity) { element.appendChild(element.getOwnerDocument().createEntityReference(entity)); }}
Code testé avec le fichier XML Suivant
Sakoba
Adams
Rappel
Ne m'oubliez pas ce week-end!