Created
October 29, 2014 16:51
-
-
Save MichaH/77344cf2bbe9ba3f81af to your computer and use it in GitHub Desktop.
A diff for two XML-InputStreams
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static boolean isSameXMLContent(InputStream s1, InputStream s2) | |
throws ParserConfigurationException, SAXException, IOException { | |
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); | |
dbf.setNamespaceAware(true); | |
dbf.setCoalescing(true); | |
dbf.setIgnoringElementContentWhitespace(true); | |
dbf.setIgnoringComments(true); | |
DocumentBuilder db = dbf.newDocumentBuilder(); | |
Document doc1 = db.parse(s1); | |
doc1.normalizeDocument(); | |
Document doc2 = db.parse(s2); | |
doc2.normalizeDocument(); | |
return doc1.isEqualNode(doc2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment