Java XML Has Child hasChild(Element start, String name)

Here you can find the source of hasChild(Element start, String name)

Description

__UNDOCUMENTED__

License

BSD License

Parameter

Parameter Description
start __UNDOCUMENTED__
name __UNDOCUMENTED__

Return

__UNDOCUMENTED__

Declaration

public static boolean hasChild(Element start, String name) 

Method Source Code


//package com.java2s;
/*// w  ww .  j  av  a  2  s .  c o  m
 * Copyright (c) 2012. betterFORM Project - http://www.betterform.de
 * Licensed under the terms of BSD License
 */

import org.w3c.dom.*;

public class Main {
    /**
     * __UNDOCUMENTED__
     *
     * @param start __UNDOCUMENTED__
     * @param name  __UNDOCUMENTED__
     * @return __UNDOCUMENTED__
     */
    public static boolean hasChild(Element start, String name) {
        NodeList nl = start.getChildNodes();
        int len = nl.getLength();

        Node n = null;

        for (int i = 0; i < len; i++) {
            n = nl.item(i);

            if (n.getNodeName().equals(name)) {
                return true;
            }
        }

        return false;
    }
}

Related

  1. hasAnyChildElement(final Element e)
  2. hasChild(Element element, String child)
  3. hasChild(Element node, String name)
  4. hasChild(Element parent, String nodeName)
  5. hasChild(Element root, String childName)
  6. hasChild(Node n)
  7. hasChildElement(Element elem, String namespace, String localName)
  8. hasChildElement(Element element, String name)
  9. hasChildElement(NodeList list)