http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/java-language-binding.html lists the properties and methods that should be available to you.
| <?xml version="1.0" encoding="UTF-8" ?> <stock andrew="was here"> <item price="50" legend="Pr-Burger" BarCode="E1" /> <item price="15" legend="Crisp S+V" BarCode="E5" /> <item price="15" legend="Crisp C+O" BarCode="E6" /> <item price="50" legend="Flat Cola" BarCode="E7" /> </stock> |
The method getElementsByTagName(t) is a handy method of Document. It returns a NodeList - this in turn has two methods item(i) and getLength()
for (int i=0;i<nl.getLength();i++){ Element e = (Element)nl.item(i); System.out.println(e.getAttribute("legend")); }