List of usage examples for org.w3c.dom Node getAttributes
public NamedNodeMap getAttributes();
NamedNodeMap
containing the attributes of this node (if it is an Element
) or null
otherwise. From source file:Main.java
public static long getLong(Node aNode, String attr, long defaultValue) { if (aNode.getAttributes().getNamedItem(attr) != null) { String attrString = aNode.getAttributes().getNamedItem(attr).getNodeValue(); Long year = Long.parseLong(attrString); return year; } else {//from ww w .j a va 2 s .c om return defaultValue; } }
From source file:Main.java
public static String getAttribute(Node node, String name) { NamedNodeMap attributes = node.getAttributes(); Node attrNode = attributes.getNamedItem(name); if (attrNode != null) return attrNode.getNodeValue(); return null;/*from www . j av a2s . com*/ }
From source file:Main.java
public static String getAttributeValue(Node node, String attribute) { Node _node = node.getAttributes().getNamedItem(attribute); return getNodeValue(_node); }
From source file:Main.java
public static String getString(Node aNode, String attr, String aDefault) { if (aNode.getAttributes().getNamedItem(attr) != null) { String docText = aNode.getAttributes().getNamedItem(attr).getNodeValue(); return docText; } else {//from ww w . jav a2s . c o m return aDefault; } }
From source file:Main.java
public static String getExperimentNameFromLineNode(Node linenode) { try {/*from w w w. j av a 2 s. c o m*/ Node t1 = linenode.getAttributes().getNamedItem("experimentname"); if (t1 != null) return t1.getNodeValue(); else return linenode.getOwnerDocument().getElementsByTagName("experimentname").item(0).getFirstChild() .getNodeValue(); } catch (NullPointerException npe) { return ""; } }
From source file:Main.java
public static int getAttributeIntValue(Node n, String item, int dflt) { final Node d = n.getAttributes().getNamedItem(item); if (d == null) { return dflt; }// w w w . ja v a 2 s.co m final String val = d.getNodeValue(); if (val == null) { return dflt; } return Integer.parseInt(val); }
From source file:Main.java
public static void removeAttribute(Node node, String attName) { NamedNodeMap attributes = node.getAttributes(); attributes.removeNamedItem(attName); }
From source file:Main.java
public static boolean getAttributeBooleanValue(Node n, String item, boolean dflt) { final Node d = n.getAttributes().getNamedItem(item); if (d == null) return dflt; final String val = d.getNodeValue(); if (val == null) return dflt; return Boolean.parseBoolean(val); }
From source file:Main.java
public static String getAttr(final Node node, String attrName) { return node == null ? null : node.getAttributes().getNamedItem(attrName).getTextContent(); }
From source file:Main.java
/** * @param node node/*from ww w .j av a 2 s . c o m*/ * @param name attribute name * @return the attribute with the given name or <code>null</code> * if none found */ public static Attr findAttribute(Node node, String name) { NamedNodeMap attrs = node.getAttributes(); if (attrs == null) { return null; } return (Attr) attrs.getNamedItem(name); }