Java: Ajouter une entité dans un élément spécifique

Author:

Java: Ajouter une entité dans un élément spécifique
Download

/***** 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 <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));  }}         

Code testé avec le fichier XML Suivant

<?xml version="1.0" encoding="windows-1252"?>
<!-- Edited by MesEXemple.com -->
<note>
	<to>Sakoba</to>
	<from>Adams</from>
	<heading>Rappel</heading>
	<body>Ne m'oubliez pas ce week-end!</body>
</note>

Cet article Java: Ajouter une entité dans un élément spécifique est apparu en premier sur .