Mega Code Archive

 
Categories / Java Tutorial / XML
 

Returns the first element that has the specified local name

import org.w3c.dom.Element; import org.w3c.dom.Node; public class Utils {   public static Element getFirstChild(Element e, String local) {     for( Node n=e.getFirstChild(); n!=null; n=n.getNextSibling() ) {         if(n.getNodeType()==Node.ELEMENT_NODE) {             Element c = (Element)n;             if(c.getLocalName().equals(local))                 return c;         }     }     return null; } }