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

Java examples for XML:XML Attribute

Description

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

Demo Code


//package com.java2s;

import org.w3c.dom.Element;

public class Main {
    /**/*w w  w.j  av a  2s.  co m*/
     * Checks if the Element contains any 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 any of the labels specified.
     */
    public static boolean hasAnyAttributes(Element element, String[] labels) {
        for (String label : labels)
            if (element.hasAttribute(label))
                return true;
        return false;
    }
}

Related Tutorials