List of utility methods to do XML Attribute Get
String | getAttributeNSOrNull(Element e, String name, String nsURI) get Attribute NS Or Null Attr a = e.getAttributeNodeNS(nsURI, name); if (a == null) return null; return a.getValue(); |
Node | getAttributeOrNull(String attribute, Element element) get Attribute Or Null if (!element.hasAttributes()) { return null; NamedNodeMap attributes = element.getAttributes(); return attributes.getNamedItem(attribute); |
String | getAttributePropertyFromElement(final Element element, final String attribute) get Attribute Property From Element return element.getAttribute(attribute);
|
Map | getAttributes(Element el) get attribute map from the element Map<String, String> list = new LinkedHashMap<String, String>(); NamedNodeMap map = el.getAttributes(); for (int i = 0; i < map.getLength(); i++) { list.put(map.item(i).getNodeName(), map.item(i).getNodeValue()); return list; |
List | getAttributes(Element el) Returns a list of attributes of an element. String nodename, prefix = null; List attrs = new Vector(); NamedNodeMap attrMap = el.getAttributes(); for (int i = 0; i < attrMap.getLength(); i++) { nodename = attrMap.item(i).getNodeName(); prefix = attrMap.item(i).getPrefix(); if (ATTR_XMLNS.equals(nodename) || ATTR_XMLNS.equals(prefix)) { continue; ... |
Map | getAttributes(Element el) get Attributes Map<String, String> retval = new HashMap<String, String>(); NamedNodeMap list = el.getAttributes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (node instanceof Attr) { Attr a = (Attr) node; retval.put(a.getName(), a.getValue()); return retval; |
Map | getAttributes(Element element) get Attributes NamedNodeMap attributes = element.getAttributes(); Map<String, String> result = new HashMap<String, String>(); int n = attributes.getLength(); for (int i = 0; i < n; i++) { Attr attribute = (Attr) attributes.item(i); result.put(attribute.getName(), attribute.getValue()); return result; ... |
Map | getAttributes(Element element) Get attributes without namespace declarations of specified element. Map<String, String> ret = new HashMap<String, String>(); NamedNodeMap attrs = element.getAttributes(); for (int i = 0; i < attrs.getLength(); i++) { Attr attr = (Attr) attrs.item(i); String attrName = attr.getName(); if (!attrName.startsWith(XMLNS_PREFIX_COLON) && !attrName.equals(XMLNS_PREFIX)) { ret.put(attrName, attr.getValue()); return ret; |
String[][] | getAttributes(Element root, String elementName, String[] wantedAttributes) get Attributes NodeList list = root.getElementsByTagName(elementName); String[][] ret = new String[list.getLength()][wantedAttributes.length]; for (int i = 0; i < list.getLength(); i++) { Element elem = (Element) list.item(i); for (int j = 0; j < wantedAttributes.length; j++) { ret[i][j] = elem.getAttribute(wantedAttributes[j]); return ret; |
Map | getAttributes(final Element el) get Attributes final Map<QName, String> attmap = new HashMap<QName, String>(); final NamedNodeMap attribs = el.getAttributes(); for (int i = 0; i < attribs.getLength(); i++) { final Attr attr = (Attr) attribs.item(i); final String name = attr.getName(); final QName qname = resolveQName(el, name); final String value = attr.getNodeValue(); attmap.put(qname, value); ... |