Seguite galera, tenho 2 arquivos xml de mesma estrutura e preciso comparar se os valores e atritutos de cada nó estão iguais.
Sugestões?
Usei o código abaixo:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setCoalescing(true);
dbf.setIgnoringElementContentWhitespace(true);
dbf.setIgnoringComments(true);
DocumentBuilder db = null;
try {
db = dbf.newDocumentBuilder();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
Document doc1 = null;
try {
doc1 = db.parse(new File("C:\\PH\\logconfig.xml"));
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
doc1.normalizeDocument();
Document doc2 = null;
try {
doc2 = db.parse(new File("C:\\PH\\logconfigVal.xml"));
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
doc2.normalizeDocument();
System.out.println("--------------------------.");
Assert.assertTrue(doc1.isEqualNode(doc2));
System.out.println("--------------------------");
return lista;
Segue o erro:
Exception in thread "main" junit.framework.AssertionFailedError
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.assertTrue(Assert.java:20)
at junit.framework.Assert.assertTrue(Assert.java:27)
at br.com.wdev.maven.plugin.checklist.rules.LogConfigRule.listaDiferencas(LogConfigRule.java:216)
at br.com.wdev.maven.plugin.checklist.rules.LogConfigRule.execute(LogConfigRule.java:115)
at br.com.wdev.maven.plugin.checklist.rulesets.Teste.main(Teste.java:29)
Se dessa forma não for a melhor, aceito novas sugestões. rsrs