// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.HashMap;
import javax.xml.parsers.*;
import org.xml.sax.*;

public class XML2HashMap {
   public static HashMap load(String fnm) throws Exception {
      HashMap res = new HashMap();
      SAXParserFactory spf = SAXParserFactory.newInstance();
      spf.setValidating(false);
      SAXParser saxParser = spf.newSAXParser();
      XMLReader xmlReader = saxParser.getXMLReader();
      xmlReader.setContentHandler(new HashMapHandler(res));
      xmlReader.parse("file:" + fnm);
      return res;
   }
}
