Java XML Element Check isNil(Element aElement)

Here you can find the source of isNil(Element aElement)

Description

Returns true if the element is null or if it has xsi:nil attribute value of "true".

License

Open Source License

Parameter

Parameter Description
aElement element to test.

Return

if element is null or nil.

Declaration

public static boolean isNil(Element aElement) 

Method Source Code

//package com.java2s;
import org.w3c.dom.*;
import javax.xml.XMLConstants;

public class Main {
    /**/*from  w  ww . ja va  2s .c o  m*/
     * Returns true if the element is null or if it has xsi:nil attribute value of "true".
     *
     * @param aElement element to test.
     * @return if element is null or nil.
     */
    public static boolean isNil(Element aElement) {
        if (aElement != null) {
            return "true".equals(aElement.getAttributeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "nil")); //$NON-NLS-1$//$NON-NLS-2$
        } else {
            return true;
        }
    }
}

Related

  1. isInfoNode(Element e)
  2. isLeaf(Element element)
  3. isLinkNode(Element e)
  4. isLocalName(Element element, String name)
  5. isMuleNamespace(Element element)
  6. isNil(Element element)
  7. isSetPrefixBeforeStartElement( XMLStreamWriter writer)
  8. isSetPrefixBeforeStartElement(XMLStreamWriter writer)
  9. isStartElement(final XMLStreamReader reader)