Parsing (COunting Elements and Attributes)

Can anyone point me to the method sfor counting elements and attributes in a parsed XML document. For example, I have a XML document that contains a number of 'word' files, I need to produce a printout that gives the total number. The files have a size attribute and I need to calculate and printout the total size of all the files together

[349 byte] By [nick211001a] at [2007-11-27 10:51:53]
# 1

http://www.google.com/search?q=parse+xml

and

http://www.google.com/search?q=parse+xml+java

ChuckBinga at 2007-7-29 11:34:08 > top of Java-index,Java Essentials,New To Java...
# 2

That would be pretty simple to do with an XSL transformation.

DrClapa at 2007-7-29 11:34:08 > top of Java-index,Java Essentials,New To Java...
# 3

ChuckBing,

Thanks for the pointers. I now have the following method:

} public void startElement(String elementName, AttributeList al) throws SAXException

{

String attributeValue;

if (elementName.equals("PRICE"))

if(al.getLength()>0)

for(int j = 0;j<al.getLength();j++)

{

attributeValue = al.getValue(j);

System.out.println("Total Attribute value is " + attributeValue);

}

This obviously allows me to extract the detail from "PRICE" but "PRICE" actually has two attributes. I can't find another method that allows me to extract out the detail for a specific attribute.

Can you suggest anything?>

nick211001a at 2007-7-29 11:34:08 > top of Java-index,Java Essentials,New To Java...