The list of methods to do XML Attribute from Node are organized into topic(s).
void
generateIds(Node root, String attrName) adds an attribute with random value to all elements, that do not have an attribute with the specified name.
if (root.getNodeType() == Node.ELEMENT_NODE) {
Element e = (Element) root;
String id = e.getAttribute(attrName);
if (id == null || id.length() == 0)
e.setAttribute(attrName, randomId());
NodeList list = root.getChildNodes();
int N = list.getLength();
...
Vector
getALLAttribute(final Node iNode)
get ALL Attribute
Vector<Attr> result = new Vector<Attr>();
if (iNode != null) {
NamedNodeMap attrList = iNode.getAttributes();
int numAttr = attrList.getLength();
Attr currentAttrNode = null;
for (int k = 0; k < numAttr; k++) {
currentAttrNode = (Attr) attrList.item(k);
result.add(currentAttrNode);
...
int
getIntAttributeRequired(Node node, String attributeName) get Int Attribute Required
String string = getStringAttributeRequired(node, attributeName);
try {
return Integer.parseInt(string);
} catch (Exception e) {
throw new Exception("Could not read integer from value '" + string + "' in attribute '" + attributeName
+ "' in node '" + node.getLocalName() + "'");