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
| public static boolean compareXmlFiles(File file1, File file2){
boolean res = false;
SAXBuilder sxb = new SAXBuilder();
try
{
Document document1 = sxb.build(file1);
Document document2 = sxb.build(file2);
Element racine1 = document1.getRootElement();
Element racine2 = document2.getRootElement();
List listChildren1 = racine1.getChildren();
List listChildren2 = racine2.getChildren();
if (listChildren1.size()!=listChildren2.size()){
res = false;
}
else{
res = true;
java.util.Iterator i = listChildren1.iterator();
java.util.Iterator j = listChildren2.iterator();
while (i.hasNext()){
Element courant1 = (Element)i.next();
System.out.println(courant1.getName());
Element courant2 = (Element)j.next();
System.out.println(courant2.getName());
if (!courant1.equals(courant2)){ //Je ne sais pas trop comment faire pour savoir si c'est identiques ou pas
res = false;
}
}
}
}
catch(Exception e){}
return res;
} |
Partager