Java: Retourner nul pour un attribut non-existant*

Author:

Java: Retourner nul pour un attribut non-existant*
{filelink=8369}

/***** Code de MesExemples.com *******/
  import org.w3c.dom.Attr;import org.w3c.dom.Element;public class Utils {  /**   * Returns null, not "", for a nonexistent attribute.   *    * @param e   * @param attributeName   * @return   */  public static String getAttributeValueEmptyNull(Element e, String attributeName) {      Attr node = e.getAttributeNode(attributeName);      if (node == null) {          return null;      }      return node.getValue();  }}         

Code testé avec le fichier XML Suivant




	Sakoba
	Adams
	Rappel
	Ne m'oubliez pas ce week-end!

A Voir sur le même Sujet:

  • code source java

Leave a Reply

Your email address will not be published. Required fields are marked *

Java: Retourner nul pour un attribut non-existant*

Author:

Java: Retourner nul pour un attribut non-existant*
{filelink=8369}

/***** Code de MesExemples.com *******/
  import org.w3c.dom.Attr;import org.w3c.dom.Element;public class Utils {  /**   * Returns null, not "", for a nonexistent attribute.   *    * @param e   * @param attributeName   * @return   */  public static String getAttributeValueEmptyNull(Element e, String attributeName) {      Attr node = e.getAttributeNode(attributeName);      if (node == null) {          return null;      }      return node.getValue();  }}         

Code testé avec le fichier XML Suivant




	Sakoba
	Adams
	Rappel
	Ne m'oubliez pas ce week-end!

Leave a Reply

Your email address will not be published. Required fields are marked *