does XML Element Contain Children - Java XML

Java examples for XML:XML Element Child

Description

does XML Element Contain Children

Demo Code


//package com.java2s;

import org.w3c.dom.Element;

public class Main {
    public static boolean doesElementContainChildren(Element parent,
            String... childNames) {
        boolean missingChild = false;
        for (String childName : childNames) {
            if (parent.getElementsByTagName(childName).getLength() == 0) {
                missingChild = true;//from www  .  jav  a  2 s.c  o m
            }
        }
        if (missingChild)
            return false;
        else
            return true;
    }
}

Related Tutorials