// 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.net.URL;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class CurrencyParse {
    public static void main(String[] args) throws Exception {
        URL url = new URL("http://www.nationalbanken.dk/dndk/valuta.nsf/valuta.xml");
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.parse(url.openStream());
        NodeList list = doc.getElementsByTagName("currency");
        for(int i = 0; i < list.getLength();i++) {
            Element curr = (Element)list.item(i);
            String code = curr.getAttribute("code");
            String desc = curr.getAttribute("desc");
            String rate = curr.getAttribute("rate");
            System.out.println(code + " " + desc + " " + rate);
        }
    }
}
