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 String getAttribute(Node node, String attribute) { return (node.getAttributes() != null && node.getAttributes().getNamedItem(attribute) != null && node.getAttributes().getNamedItem(attribute).getNodeValue() != null && node.getAttributes().getNamedItem(attribute).getNodeValue().length() > 0) ? node.getAttributes().getNamedItem(attribute).getNodeValue() : null;//from ww w .j a v a2 s .c o m }
From source file:Main.java
public static String getAttributeValue(Node n, String item) { final Node d = n.getAttributes().getNamedItem(item); if (d == null) return ""; final String val = d.getNodeValue(); if (val == null) return ""; return val; }
From source file:Main.java
public static String getAttributeValue(Node node, String attribute) { return node.getAttributes().getNamedItem(attribute) != null ? node.getAttributes().getNamedItem(attribute).getNodeValue() : ""; }
From source file:Main.java
public static Map<String, String> getAttributes(Node node) { NamedNodeMap map = node.getAttributes(); Map<String, String> result = Maps.newHashMap(); if (map != null) { for (int i = 0; i < map.getLength(); i++) { result.put(map.item(i).getNodeName(), map.item(i).getNodeValue()); }/*from ww w. j a v a2 s. com*/ } return result; }
From source file:Main.java
private static void clearAttributes(Node node) { final NamedNodeMap attributes = node.getAttributes(); while (attributes.getLength() > 0) { attributes.removeNamedItem(attributes.item(0).getNodeName()); }/*from www . j av a 2s .c om*/ }
From source file:Main.java
public static String getNodeProperty(Node node, String key) { NamedNodeMap attributes = node.getAttributes(); Node item = attributes.getNamedItem(key); return item == null ? null : item.getTextContent(); }
From source file:Main.java
private static void traverseAttributes(JsonObject childJson, Node childNode) { NamedNodeMap attrNodeMap = childNode.getAttributes(); for (int j = 0; j < attrNodeMap.getLength(); j++) { Node attrNode = attrNodeMap.item(j); childJson.addProperty("-" + attrNode.getNodeName(), attrNode.getNodeValue()); }/* www. j a v a2 s . c o m*/ }
From source file:Main.java
public static final String getAttributeValue(Node element, String attribute) { return element.getAttributes().getNamedItem(attribute).getNodeValue(); }
From source file:Main.java
/** * Returns whether the given XML DOM node contains the given attribute. * @param node the XML node to examine//from w w w.j av a2s.c om * @param name an attribute name to check * @return true if the attribute exists, false if not */ public static boolean hasAttribute(Node node, String name) { return node.getAttributes().getNamedItem(name) != null; }
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; final String val = d.getNodeValue(); if (val == null) return dflt; return Integer.parseInt(val); }