The list of methods to do XML Attribute from Element are organized into topic(s).
Element
getElement(Element root, String tagName, String attrName, String attrValue) get Element
if (root.getTagName().equals(tagName)) {
if (attrName == null) {
return (root);
if (root.getAttribute(attrName).equals(attrValue)) {
return (root);
NodeList list = root.getElementsByTagName(tagName);
for (int i = 0; i < list.getLength(); i++) {
Element el = (Element) list.item(i);
if (attrName == null) {
return (el);
if (el.getAttribute(attrName).equals(attrValue)) {
return (el);
return (null);
int[]
getElementArrayInt(Element root, String name, String attrib) Takes a number of tags of name 'name' that are children of 'root', and looks for attributes of 'attrib' on them.
if (root == null)
return null;
NodeList nl = root.getChildNodes();
LinkedList elementCache = new LinkedList();
int size = nl.getLength();
for (int i = 0; i < size; i++) {
Node node = nl.item(i);
if (!(node instanceof Element))
...
String[]
getElementArrayString(Element root, String name, String attrib) Takes a number of tags of name 'name' that are children of 'root', and looks for attributes of 'attrib' on them.
if (root == null)
return null;
NodeList nl = root.getChildNodes();
LinkedList elementCache = new LinkedList();
int size = nl.getLength();
for (int i = 0; i < size; i++) {
Node node = nl.item(i);
if (!(node instanceof Element))
...
String
getElementAttribute(Element root, String elemName, String att) get the value of an Attribute in the Xml Document.
NodeList nl = root.getElementsByTagName(elemName);
if (null == nl) {
return (null);
Node n = nl.item(0);
if (null == n) {
return (null);
NamedNodeMap attributes = n.getAttributes();
if (null == attributes) {
return (null);
n = attributes.getNamedItem(att);
if (null == n) {
return (null);
return (n.getNodeValue().trim());
String
getElementAttributes(Element element, List exclude) get Element Attributes
StringBuffer buffer = new StringBuffer();
if (element != null) {
NamedNodeMap attributes = element.getAttributes();
if (attributes != null) {
for (int i = 0; i < attributes.getLength(); i++) {
Attr attr = (Attr) attributes.item(i);
if (!exclude.contains(attr.getNodeName())) {
buffer.append(attr.getNodeName() + "=");
...