List of usage examples for org.w3c.dom Element getAttribute
public String getAttribute(String name);
From source file:Main.java
public static boolean getBooleanAttribute(Element el, String name) { String s = el.getAttribute(name); if (s == null || "0".equals(s)) { return false; }//from w w w. java 2s .com if ("1".equals(s)) { return true; } return Boolean.getBoolean(s); }
From source file:Main.java
public static String getAttribByName(Element node, String name) { return node.getAttribute(name); }
From source file:Main.java
public static Element getElementByAttributeValue(List<Element> elements, String attName, String attValue) { for (Element e : elements) { String s = e.getAttribute(attName); if (attValue.equals(s)) return e; }// w w w .jav a2 s .co m return null; }
From source file:Main.java
/** * Returns the content of the specified attribute in the specified node. * @param node The node containing the desired attribute. * @param attributeName The name of the desired attribute. * @return The text of the specified attribute. If the attribute doesn't exist * in the specified node, the method returns an empty string. *//*from w w w . ja v a 2 s . co m*/ public static String GetNodeAttribute(Node node, String attributeName) { Element x = (Element) node; return x.getAttribute(attributeName); }
From source file:Main.java
/** * Traverses the passed Element <var>e</var> and sets the "id" attribute to * be the user-defined ID attribute. This method recursively visits all * children of the parent Element <var>e</var>. This is used to find * elements by their ID//www . j a v a 2 s . c o m * * @param e */ private static void defineIDAttribute(Element e) { if (e.getAttribute("id").length() > 0) e.setIdAttribute("id", true); for (Node child = e.getFirstChild(); child != null; child = child.getNextSibling()) if (child.getNodeType() == Document.ELEMENT_NODE) defineIDAttribute((Element) child); }
From source file:Main.java
public static String getAttribute(Element element, String name) { return element.getAttribute(name); }
From source file:Main.java
public static boolean getBooleanAttribute(Element el, String name) { String s = el.getAttribute(name); if (s == null || "0".equals(s)) { return false; }/*from ww w .ja v a 2 s. com*/ if ("1".equals(s)) { return true; } return new Boolean(s).booleanValue(); }
From source file:Main.java
public static String getAttribute(NodeList nodeList, String attName) { Element elm = (Element) nodeList.item(0); return elm.getAttribute(attName); }
From source file:Main.java
public static String parseString(Element element, String key) { String value = element.getAttribute(key); if (value != null && !value.isEmpty()) { return value; }//from w ww .j av a 2 s . c om return null; }
From source file:Main.java
public static String getAttribute(Element element, String attr) { String value = element.getAttribute(attr).trim(); return value.equals("") ? null : value; }