
class XmlTest {
    public XmlTest(String fileName) {
	org.w3c.dom.Document document;  
	javax.xml.parsers.DocumentBuilderFactory factory = 
	    javax.xml.parsers.DocumentBuilderFactory.newInstance();
	try {
	    javax.xml.parsers.DocumentBuilder builder = factory.newDocumentBuilder();
	    document = builder.parse( new java.io.File(fileName) );
            org.w3c.dom.NodeList rootChild = document.getChildNodes();
            org.w3c.dom.Node racine = rootChild.item(0);
	    System.out.println("Noeud racine : "+racine.getNodeName());
	    org.w3c.dom.NamedNodeMap m = racine.getAttributes();
	    System.out.println(" id="+m.getNamedItem("id").getNodeValue());
	    org.w3c.dom.NodeList children = racine.getChildNodes();
	    if ( children != null ) {
		int len = children.getLength();
		for ( int i = 0; i < len; i++ ) {
		    org.w3c.dom.Node n = (org.w3c.dom.Node)children.item(i);
		    System.out.println("  sous-noeud : "+n.getNodeName());
		}
	    }
	} catch (org.xml.sax.SAXException sxe) {
	    // Erreur durant le parcours
	    Exception  x = sxe;
	    if (sxe.getException() != null)
		x = sxe.getException();
	    x.printStackTrace();
	} catch (javax.xml.parsers.ParserConfigurationException pce) {
	    // Impossible de construire le parser avec les options donnees
	    pce.printStackTrace();
	} catch (java.io.IOException ioe) {
	    // Erreur d'entree/sortie
	    ioe.printStackTrace();
	}
    }
    public static void main(String arg[]) {
	if (arg.length!=1) {
	    System.err.println("Un argument attendu!");
	    System.exit(1);
	}
	XmlTest xml = new XmlTest(arg[0]);
    }
}
