If you implement the ContentHandler interface and use that with your sax parser it works a lot better. Then the following code will get you what you are looking for, I think.
public void startElement(String uri, String localName, String qName, Attributes attr)
throws SAXException
{
String type = attr.getValue("TYPE");
if (type != null)
{
if (total.containsKey(type))
{
//Java 1.5 autoboxing will take care of this for you
int temp = (Integer)total.get(type);
total.put(type, new Integer(temp+1));
}
else if (!total.containsKey(type))
total.put(type, new Integer(1));
}
}
public void endDocument()
{
Iterator i = total.entrySet().iterator();
while (i.hasNext())
{
Map.Entry temp = (Map.Entry)i.next();
System.out.println(temp.getKey() + " " + temp.getValue());
}
}