Java XML Attribute from Node getNonEmptyAttribute(Element element, String namespace, String localName)

Here you can find the source of getNonEmptyAttribute(Element element, String namespace, String localName)

Description

get Non Empty Attribute

License

Open Source License

Declaration

public static String getNonEmptyAttribute(Element element,
            String namespace, String localName) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Element;

public class Main {
    public static String getNonEmptyAttribute(Element element,
            String namespace, String localName) {
        String value = element.getAttributeNS(namespace, localName);
        if (value == null || (value = value.trim()).length() == 0 ||
        // "???" is a placeholder value often used by XMLmind XML Editor.
                "???".equals(value)) {
            value = null;//w  w  w  .jav  a2 s .c om
        }
        return value;
    }
}

Related

  1. getNodeAttributeValue(Node node, String attributeName)
  2. getNodeAttributeValue(Node node, String attrName)
  3. getNodeAttributeValueNS(Node node, String namespaceURI, String attrName)
  4. getNodeMap(NamedNodeMap artifactAttributes)
  5. getNodesByAttributeValue(Node node, String attrName, String attrValue)
  6. getStringAttributeOptional(Node node, String attributeName, String valueIfEmpty)
  7. getStringAttributeRequired(Node node, String attributeName)
  8. getValueForAttribute(Node currentNode, String attributeName)
  9. getXMLDate(Element e, String attrName)