Java XML Has Child hasChild(Node n)

Here you can find the source of hasChild(Node n)

Description

has Child

License

Open Source License

Declaration

private static boolean hasChild(Node n) 

Method Source Code

//package com.java2s;
/*//from  www  . ja  v a 2 s .  c  om
 *  Copyright 2010-2011 the original author or authors.
 *
 *  WebServiceMocker is free software; you can redistribute it and/or modify it under the 
 *  terms of version 2.1 of the GNU Lesser General Public License as published by 
 *  the Free Software Foundation.
 *
 *  WebServiceMocker is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
 *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 *  See the GNU Lesser General Public License for more details at gnu.org.
 */

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    private static boolean hasChild(Node n) {

        NodeList nl = n.getChildNodes();

        for (int i = 0; i < nl.getLength(); i++) {
            n = nl.item(i);
            if (n.getNodeType() == 1)
                return true;
        }
        return false;
    }
}

Related

  1. hasChild(Element element, String child)
  2. hasChild(Element node, String name)
  3. hasChild(Element parent, String nodeName)
  4. hasChild(Element root, String childName)
  5. hasChild(Element start, String name)
  6. hasChildElement(Element elem, String namespace, String localName)
  7. hasChildElement(Element element, String name)
  8. hasChildElement(NodeList list)
  9. hasChildElement(TreeWalker walker)