1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| package com.XML;
import java.io.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.filter.*;
import java.util.List;
import java.util.Iterator;
public class ReaderXML
{
/*-------------------------- création de l'element racine -------------------*/
static Element racine ;
/*----- creation d'un nouveau document basé sur la racine -------------------*/
static org.jdom.Document document;
/*----- afficherAll(), permet d'afficher les elements du document XML--------*/
static void afficherAll(Element racine ,org.jdom.Document document )
{
List liste = racine.getChildren("typeInformation");
Iterator i = liste.iterator();
List ll =null;
while (i.hasNext())
{
org.jdom.Element courant = (Element)i.next();
System.out.println( courant.getName());
System.out.println(courant.getChild("nomTypeInformation").getText());
System.out.println(courant.getChild("delaisTypeInformation").getText());
System.out.println(racine.getChild("typeInformation").getChild("unitesInformations").getChild("uniteInformation").getChild("nom").getText());//.getChild("page").getAttributeValue("name"));
System.out.println(racine.getChild("typeInformation").getChild("unitesInformations").getChild("uniteInformation").getChild("prenom").getText());//.getChild("page").getAttributeValue("name"));
System.out.println();
}
}
} |