/***** Code de MesExemples.com *******/
/**
 * @(#)XMLFindSpecificNode.java
 *
 *
 * @author 
 *sakoba(java.mesexemples.com) @version 1.00 2013/7/5
 */
import org.w3c.dom.Node;
public class XMLFindSpecificNode {
  /**
   * Search up the tree for a given node
   * @param currentNode Starting point for our search
   * @param tagName Node name to look up
   * @return matching Node (null if none)
   */
  public static Node getPreviousNodeByName(Node currentNode, String tagName) {
    Node node = currentNode.getParentNode();
    while ((node != null) && (!node.getNodeName().equals(tagName))) {
      node = node.getParentNode();
    }
    return node;
  }
}
Code testé avec le fichier XML Suivant
	Sakoba 
	Adams 
	Rappel 
	Ne m'oubliez pas ce week-end!
 
    