本文整理匯總了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);
}