List of utility methods to do XML Attribute Get
String[] | getAttributeNames(Element el) Gets a list of all attribute names for the given DOM element. NamedNodeMap map = el.getAttributes(); int len = map.getLength(); String[] attrNames = new String[len]; for (int i = 0; i < len; i++) { Attr attr = (Attr) map.item(i); attrNames[i] = attr == null ? null : attr.getName(); return attrNames; ... |
List | getAttributeNames(Element element) get Attribute Names List<String> names = new ArrayList<String>(); NamedNodeMap list = element.getAttributes(); for (int i = 0; i < list.getLength(); i++) { names.add(list.item(i).getNodeName()); return names; |
List | getAttributeNames(final Element e) Get a list of the attribute names of an element. if (e == null) { return null; final List<String> result = new ArrayList<>(); final NamedNodeMap map = e.getAttributes(); for (int i = 0; i < map.getLength(); i++) { final Node attribute = map.item(i); result.add(attribute.getNodeName()); ... |
Node | getAttributeNode(Node sNode, String attribName) Decide if the node is text, and so must be handled specially NamedNodeMap attrs = sNode.getAttributes(); if (attrs != null) { return attrs.getNamedItem(attribName); return null; |
Node | getAttributeNode(Node sNode, String attribName) get Attribute Node NamedNodeMap attrs = sNode.getAttributes(); if (attrs != null) { return attrs.getNamedItem(attribName); return null; |
List | getAttributeNodeList(Element element, Pattern name) get Attribute Node List NamedNodeMap nodes = element.getAttributes(); List<Node> attributes = new ArrayList<>(); int i, size = nodes.getLength(); Node node; for (i = 0; i < size; i++) { node = nodes.item(i); if (name.matcher(node.getNodeName()).find()) attributes.add(node); ... |
String | getAttributeNS(Element el, String namespaceURI, String localPart) Returns the value of an attribute of an element. String sRet = null; Attr attr = el.getAttributeNodeNS(namespaceURI, localPart); if (attr != null) { sRet = attr.getValue(); return sRet; |
String | getAttributeNS(Element elem, String namespace, String att) get Attribute NS String res = elem.getAttributeNS(namespace, att);
return res.length() == 0 && !elem.hasAttributeNS(namespace, att) ? null : res;
|
QName | getAttributeNSName(Element e, String attrName) get Attribute NS Name String attrValue = e.getAttribute(attrName);
return getNSName(e, attrValue);
|
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(); |