List of utility methods to do XML Attribute Get
Map | getAttributes(Node node) get Attributes Map<QName, String> atts = new HashMap<QName, String>(); NamedNodeMap nnm = node.getAttributes(); if (nnm != null) { for (int i = 0; i < nnm.getLength(); i++) { Attr att = (Attr) nnm.item(i); String uri = att.getBaseURI(); String localname = att.getLocalName(); String prefix = att.getPrefix(); ... |
Map | getAttributes(Node node) get Attributes 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()); return result; ... |
Map | getAttributes(Node node) Creates a map from the attributes of a Node NamedNodeMap attributeMap = node.getAttributes(); HashMap<String, String> attributes = new HashMap<String, String>(attributeMap.getLength()); for (int i = 0; i < attributeMap.getLength(); i++) { Node attr = attributeMap.item(i); if (attr instanceof Attr) { attributes.put(((Attr) attr).getName(), ((Attr) attr).getValue()); return attributes; |
void | getAttributes(String element, String xsd) get Attributes final SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); try { sf.newSchema(new File("customer.xsd")); } catch (final SAXException e) { e.printStackTrace(); |
List | getAttributes(XMLEvent evt) get Attributes List<Attribute> ret = new ArrayList<Attribute>(); if (evt.isStartElement()) { StartElement start = evt.asStartElement(); Iterator<Attribute> iterator = start.getAttributes(); while (iterator.hasNext()) { ret.add(iterator.next()); return ret; |
Map | getAttributesAsMap(Element e) Return the attributes from the specified element as a Map Map<String, String> result = new HashMap<String, String>(); NamedNodeMap attrs = e.getAttributes(); if (attrs != null) { int len = attrs.getLength(); for (int i = 0; i < len; i++) { Node n = attrs.item(i); if (n instanceof Attr) { Attr a = (Attr) n; ... |
HashMap | getAttributesByName(Node node, ArrayList Puts the node attributes (if it has any) into HashMap String attrName = null; String attrValue = null; HashMap<String, String> attributesMap = new HashMap<String, String>(); NamedNodeMap attributes = node.getAttributes(); for (int attrIndex = 0; attrIndex < attributes.getLength(); attrIndex++) { attrName = attributes.item(attrIndex).getNodeName(); attrValue = attributes.item(attrIndex).getNodeValue(); if (attrNames.contains(attrName)) { ... |
String | getAttributesCompact(NamedNodeMap attributes) get Attributes Compact String s = "["; for (int i = 0; i < attributes.getLength(); ++i) { Node n = attributes.item(i); s += n.getNodeName() + "=\"" + n.getNodeValue() + "\""; s += ", "; s += "]"; return s; ... |
String[] | getAttributesNamesOf(Element element) Gets the names of all the attributes of the given Element . final NamedNodeMap map = element.getAttributes(); final int numAttributes = map.getLength(); final String[] result = new String[numAttributes]; for (int i = 0; i < numAttributes; ++i) result[i] = map.item(i).getNodeName(); return result; |
String | getAttributeString(Node node, String name) Gets the value of a named attribute of a node. Node nd = findAttribute(node, name); if (nd != null) return nd.getNodeValue(); return null; |