Checks if the XML Element contains all of the attributes contained in the list of labels. - Java XML

Java examples for XML:XML Attribute

Description

Checks if the XML Element contains all of the attributes contained in the list of labels.

Demo Code


//package com.java2s;

import org.w3c.dom.Element;

public class Main {
    /**//from   ww w.  java 2  s  .  c om
     * Checks if the Element contains all of the attributes contained in the
     * list of labels.
     *
     * @param element
     *            The Element object.
     * @param labels
     *            The list of string labels to test.
     * @return If the Element contains all of the labels specified.
     */
    public static boolean hasAllAttributes(Element element, String[] labels) {
        for (String label : labels)
            if (!element.hasAttribute(label))
                return false;
        return true;
    }
}

Related Tutorials