Saturday 6 August 2011

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) {
    forNode 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;
}

}

   
    
  

No comments:

Post a Comment