Mega Code Archive

 
Categories / Java Tutorial / XML
 

Add an entity to a specified Element

import org.w3c.dom.Document; import org.w3c.dom.Element; public class Utils {   /**    * Add an entity to a specified Element.    *    (eg <code>DomUtils.addEntity(element, "nbsp");</code>)    * @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));   } }