Java XML Attribute Get getDivHeadAttr(Element annotU, String attrName)

Here you can find the source of getDivHeadAttr(Element annotU, String attrName)

Description

get Div Head Attr

License

Open Source License

Declaration

public static String getDivHeadAttr(Element annotU, String attrName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

public class Main {
    public static String getDivHeadAttr(Element annotU, String attrName) {
        String a = annotU.getAttribute(attrName);
        if (a == null || a.isEmpty())
            return getHeadAttr(annotU, attrName);
        return a;
    }/*from  w  ww .ja va2s .c  om*/

    public static String getHeadAttr(Element annotU, String attrName) {
        NodeList nl = annotU.getElementsByTagName("head");
        if (nl == null)
            return "";
        Element head = (Element) nl.item(0);
        if (head == null)
            return "";
        NodeList notes = head.getElementsByTagName("note");
        for (int i = 0; i < notes.getLength(); i++) {
            Element e = (Element) (notes.item(i));
            String a = e.getAttribute("type");
            if (a.equals(attrName))
                return e.getTextContent();
        }
        return "";
    }
}

Related

  1. getCascadeValue(final Element elem, final String attrName)
  2. getClosestAncestorWithAttribute(Node node, String ancestorName, String attributeName)
  3. getClosestAncestorWithAttribute(Node node, String ancestorName, String attributeName)
  4. getCurrentLevelAttributeTextValue(Element ele, String attribute)
  5. getDirectAttribute(Node node, String name)
  6. getDoubleArrayTagAttribute(XMLStreamReader xmler, String attribute, double[] defaultValue)
  7. getDoubleAttribute(Element element, String name)
  8. getDoubleAttribute(Node n, String s)
  9. getDoubleAttribute(String name, Element el)