1 37 package net.sourceforge.cruisecontrol; 38 39 import org.jdom.Document; 40 import org.jdom.Element; 41 42 import java.util.Iterator ; 43 import java.util.List ; 44 45 public final class JDOMSearcher { 46 47 private JDOMSearcher() { 48 } 49 50 public static Element getElement(Document doc, String name) { 51 return findElement(doc.getRootElement(), name); 52 } 53 54 protected static Element findElement(Element parent, String name) { 55 if (parent.getName().equals(name)) { 56 return parent; 57 } 58 59 List children = parent.getChildren(); 60 for (Iterator i = children.iterator(); i.hasNext();) { 61 Element child = (Element) i.next(); 62 Element tmp = findElement(child, name); 63 if (tmp != null) { 64 return tmp; 65 } 66 } 67 68 return null; 69 } 70 } 71 | Popular Tags |