XMLDiff\DOM 可以这样使用,用于比较 XML 文件的更改。
<?php
function getChangeElements($currentContent, $oldContent) {
try {
$currentDoc = new DOMDocument();
$currentDoc->loadXML($currentContent);
$oldDoc = new DOMDocument();
$oldDoc->loadXML($oldContent);
$xmldiff = new XMLDiff\DOM();
return $xmldiff->diff($oldDoc, $currentDoc);
} catch (Exception $ex) {
throw $ex;
}
}
getChangeElements('updated.xml', 'old.xml');
?>