An example on how to use getAttribute would be nice. Or at least point me to an example or doc that describes how to use it.
I've tried using getAttribute, as seen below, but it raises a "java.lang.ClassCastException" exception.
Code:
ByteArrayInputStream stream = new ByteArrayInputStream(data.getBytes());
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringElementContentWhitespace(true);
factory.setAllowUndefinedNamespaces(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(stream);
Element root = doc.getDocumentElement();
Element operation = (Element) root.getOwnerDocument();
String _layer = operation.getAttribute("Category");
System.out.println("Category: " + _layer);
NodeList list = doc.getElementsByTagName("*");
_node = new String();
_element = new String();
for (int i=0;i<list.getLength();i++) {
Node value = list.item(i).getChildNodes().item(0);
_node = list.item(i).getNodeName();
_element = value.getNodeValue();
System.out.println("Node:Element = " + _node + ":" + _element);
}
__________________
===================================
"There are 10 types of people in the world.
Those that understand binary and those that don't!"
www.timothytrimble.info - The ART of S/W Development
==================================