List of usage examples for org.w3c.dom Element getAttribute
public String getAttribute(String name);
From source file:Main.java
public static float getFloat(Element element, String attributeName) { return Float.parseFloat(element.getAttribute(attributeName)); }
From source file:Main.java
public static URL getAttribURL(Element ele, String name, URL docRoot) { String sval = ele.getAttribute(name); try {/* w ww . j a va 2s . c o m*/ return new URL(docRoot, sval); } catch (Exception e) { return null; } }
From source file:Main.java
public static Element get_child_with_attr(Node parent, String child_name, String attr_name, String attr_value) { NodeList children = parent.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { Node child = children.item(i); if (child.getNodeName().equals(child_name)) { if (child instanceof Element) { Element e = (Element) child; if (e.getAttribute(attr_name).equals(attr_value)) return e; }/* ww w . jav a 2s . c o m*/ } } return null; }
From source file:Main.java
public static String getStringAttr(Element element, String name) { String attr = element.getAttribute(name); return attr;/*from w w w. j a v a 2 s. c o m*/ }
From source file:Main.java
/** * Parses the given attribute of this tag and returns it as an int. *///ww w. j av a 2 s .c o m public static int getAttribInt(Element ele, String name) { String sval = ele.getAttribute(name); int val = 0; try { val = Integer.parseInt(sval); } catch (Exception e) { } return val; }
From source file:Main.java
public static Double getDoubleAttr(Element element, String name) { String attr = element.getAttribute(name); if (!attr.isEmpty()) { Double ret = Double.valueOf(attr); return ret; }/*from w w w. j a v a2s.c om*/ return null; }
From source file:Main.java
public static String getAttribute(Element element, String attr, String defValue) { String value = element.getAttribute(attr).trim(); return value.equals("") ? defValue : value; }
From source file:Main.java
/** * Parses the given attribute of this tag as a hexadecimal encoded string and * returns it as an int// w w w . jav a 2 s . com */ public static int getAttribIntHex(Element ele, String name) { String sval = ele.getAttribute(name); int val = 0; try { val = Integer.parseInt(sval, 16); } catch (Exception e) { } return val; }
From source file:Main.java
static String getOptionalAttribute(Element elt, String name) { String value = elt.getAttribute(name); if (value.equals("")) { return null; } else {//from w ww.jav a2 s. co m return value; } }
From source file:Main.java
/** * Helper function for quickly retrieving an attribute from a given * element. /*from w ww . java 2 s .c om*/ * @param ele The document element from which to pull the attribute value. * @param attrName The name of the attribute. * @return The value of the attribute contained within the element */ public static String getAttributeValue(Element ele, String attrName) { return decode(ele.getAttribute(attrName)); }