List of usage examples for org.w3c.dom NamedNodeMap getNamedItem
public Node getNamedItem(String name);
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
public static String getField(NamedNodeMap fields, String fieldName) { Node field = fields.getNamedItem(fieldName); if (field != null) return field.getNodeValue(); else//from w w w .jav a2 s . c o m return new String(); }
From source file:Main.java
public static String getAttribute(NamedNodeMap namedNodeMap, String name) { Node node = namedNodeMap.getNamedItem(name); if (node == null) { return null; }/* w w w. j a va2 s .co m*/ return node.getNodeValue(); }
From source file:Main.java
public static String getAttributeValue(final Element base, final String name) { // get attribute of this element... NamedNodeMap mapAttributes = base.getAttributes(); Node node = mapAttributes.getNamedItem(name); if (node != null) { return node.getNodeValue(); }//from w w w .jav a 2s. c o m return null; }
From source file:Main.java
public static void removeNodeAttribute(Node node, String name) { if (node.hasAttributes()) { NamedNodeMap attrs = node.getAttributes(); if (attrs.getNamedItem(name) != null) { attrs.removeNamedItem(name); }//from ww w . ja v a 2 s . co m } }
From source file:Main.java
public static String getPath(Node node) { NamedNodeMap nodeMap = node.getAttributes(); Node pathNode = nodeMap.getNamedItem("path"); if (pathNode != null) { return pathNode.getNodeValue(); } else//from w w w . jav a2 s . com return null; }
From source file:Main.java
/** * Method getAttr.// w ww .j a v a2 s .c o m * <br>Returns the Attribute with the given attrName at node * <br>Example<br> * This example returns the 'state' attribute from the address node: * Attr state = getAttr(address,"state") * @param node - Node to search * @param attrName - Name of the attribute to find * @return Attr - Attribute found */ public static Attr getAttr(Node node, String attrName) { NamedNodeMap attrs = node.getAttributes(); return (Attr) attrs.getNamedItem(attrName); }
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;/* w w w.jav a 2 s.com*/ }
From source file:Main.java
/** * Gets the attribute of the node./*from w w w . j av a 2 s . co m*/ * *@param node the node from which to get the attribute node *@param name the attribute name for which to get the node *@return The attribute node *@exception DOMException if an error occurs while getting the attribute * node */ public final static Node getAttribute(Node node, String name) throws DOMException { if (node != null && node.hasAttributes()) { NamedNodeMap attrs = node.getAttributes(); return attrs.getNamedItem(name); } return null; }
From source file:Main.java
public static Point toPoint(Node n) { if (!n.getNodeName().equals("center")) { throw new IllegalArgumentException(n.getNodeName()); }//w w w . j a va 2s. c om NamedNodeMap map = n.getAttributes(); int x = Integer.parseInt(map.getNamedItem("x").getNodeValue()); int y = Integer.parseInt(map.getNamedItem("y").getNodeValue()); return new Point(x, y); }