XMLDiff\DOM::diff
(PECL xmldiff >= 0.8.0)
XMLDiff\DOM::diff — Diff two DOMDocument objects
説明
Diff two DOMDocument instances and produce the new one containing the diff information.
パラメータ
from
-
Source DOMDocument object.
to
-
Target DOMDocument object.
戻り値
DOMDocument with the diff information or NULL.
+add a note
User Contributed Notes 1 note
jeewiya at gmail dot com ¶
6 years ago
XMLDiff\DOM can be use like this, for compare xml files changes.
<?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');
?>
↑ and ↓ to navigate •
Enter to select •
Esc to close
Press Enter without
selection to search using Google