Java XML Attribute from Element getHeadAttr(Element annotU, String attrName)

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

Description

get Head Attr

License

Open Source License

Declaration

public static String getHeadAttr(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 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();
        }/* w w  w  .j a  v  a 2 s. com*/
        return "";
    }
}

Related

  1. getElementTextByAttr(Element modsroot, String nodename, String attrname, String attrvalue)
  2. getElementValues(final String elementName, final String attributeValue, final InputStream is)
  3. getFirstAttribute(Element elem, String name, String attrName)
  4. getFloatAttribute(Element element, String name)
  5. getFloatAttribute(String name, Element el)
  6. getIdAttribute(Element domElement)
  7. getIdAttributeValue(Element elem, String name)
  8. getIntAttr(Element elem, String attName)
  9. getIntAttribute(Element el, String name)