XMLDiff\DOM::diff

(PECL xmldiff >= 0.8.0)

XMLDiff\DOM::diffDiff two DOMDocument objects

Description

public XMLDiff\DOM::diff(DOMDocument $from, DOMDocument $to): DOMDocument

Diff two DOMDocument instances and produce the new one containing the diff information.

Parameters

from

Source DOMDocument object.

to

Target DOMDocument object.

Return Values

DOMDocument with the diff information or NULL.

add a note

User Contributed Notes 1 note

up
1
jeewiya at gmail dot com
7 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');

?>
To Top

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant