本文整理汇总了Java中org.w3c.dom.Document.isEqualNode方法的典型用法代码示例。如果您正苦于以下问题:Java Document.isEqualNode方法的具体用法?Java Document.isEqualNode怎么用?Java Document.isEqualNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.Document
的用法示例。
在下文中一共展示了Document.isEqualNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareDocumentWithGold
import org.w3c.dom.Document; //导入方法依赖的package包/类
/**
* Compare contents of golden file with test output file by their document
* representation.
* Here we ignore the white space and comments. return true if they're
* lexical identical.
* @param goldfile Golden output file name.
* @param resultFile Test output file name.
* @return true if two file's document representation are identical.
* false if two file's document representation are not identical.
* @throws javax.xml.parsers.ParserConfigurationException if the
* implementation is not available or cannot be instantiated.
* @throws SAXException If any parse errors occur.
* @throws IOException if an I/O error occurs reading from the file or a
* malformed or unmappable byte sequence is read .
*/
public static boolean compareDocumentWithGold(String goldfile, String resultFile)
throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setCoalescing(true);
factory.setIgnoringElementContentWhitespace(true);
factory.setIgnoringComments(true);
DocumentBuilder db = factory.newDocumentBuilder();
Document goldD = db.parse(Paths.get(goldfile).toFile());
goldD.normalizeDocument();
Document resultD = db.parse(Paths.get(resultFile).toFile());
resultD.normalizeDocument();
return goldD.isEqualNode(resultD);
}