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 Boolean getAttributeValueAsBoolean(Node node, String attributeName) { final Node attributeNode = node.getAttributes().getNamedItem(attributeName); return attributeNode != null ? Boolean.parseBoolean(attributeNode.getTextContent()) : null; }
From source file:Main.java
/** * Returns string value of the named attribute of the node. * Returns <code>null</code> if such attribute does not exist. * * @param node The node to extract attribute from * @param attrName The name of the attribute * * @return String value of the attribute or <code>null</code> * * @throws NullPointerException If <code>node</code> is <code>null</code> *///from w ww. j a v a 2s . c om public static String getAttributeValue(Node node, String attrName) { Node attr = node.getAttributes().getNamedItem(attrName); return attr == null ? null : attr.getNodeValue(); }
From source file:Main.java
public static String getNodeAttribute(Node node, String name) { return getNamedItemNodeValue(node.getAttributes(), name, null); }
From source file:Main.java
public static Integer getAttributeValueAsInteger(Node node, String attributeName) { final Node attributeNode = node.getAttributes().getNamedItem(attributeName); return attributeNode != null ? Integer.parseInt(attributeNode.getTextContent()) : null; }
From source file:Main.java
public static String getAtrributeValue(Node node, String attribute) { Node _node = node.getAttributes().getNamedItem(attribute); return getNodeValue(_node); }
From source file:Main.java
/** * Insert the method's description here. * // ww w . j a va 2 s .c om * @return java.lang.String * @param element * org.w3c.dom.Node * @param attributeName * java.lang.String */ public static String getNodeAttributeValue(Node element, String attributeName) { Node tmpNode = element.getAttributes().getNamedItem(attributeName); String tmp = null; if (tmpNode != null) tmp = tmpNode.getNodeValue(); return tmp; }
From source file:Main.java
/** * Gets the content of an attribute.//from ww w . j ava 2 s . c o m * For example, * <item attributeName="content" /> */ public static Optional<String> getAttributeContent(Node item, String attributeName) { NamedNodeMap attributes = item.getAttributes(); return Optional.ofNullable(attributes.getNamedItem(attributeName)).map(Node::getTextContent); }
From source file:com.l2jfree.gameserver.model.zone.form.Tupel.java
public static Tupel parseTupel(Node n, int zoneId) { if (n.getAttributes().getNamedItem("x") == null || n.getAttributes().getNamedItem("y") == null) { _log.error("x or y value missing in zone " + zoneId); return null; }/*from ww w .j a va2 s. c o m*/ try { Tupel t = new Tupel(); t.x = Integer.parseInt(n.getAttributes().getNamedItem("x").getNodeValue()); t.y = Integer.parseInt(n.getAttributes().getNamedItem("y").getNodeValue()); return t; } catch (NumberFormatException nfe) { _log.error("x or y value not a number in zone " + zoneId); } return null; }
From source file:Main.java
/** * //www. j ava 2 s.co m * @param node * @param name * @return */ public static String getStringAttribute(Node node, String name) { Node attribute = node.getAttributes().getNamedItem(name); if (attribute != null) { return attribute.getNodeValue(); } else { return null; } }
From source file:Main.java
public static String getNodeAttribute(Node node, String name) { NamedNodeMap map = node.getAttributes(); Node n = map.getNamedItem(name); if (n != null) { return n.getNodeValue(); }//from w w w. j a va 2 s . c o m return null; }