I got this code to search for a duplicate (of the employee Jane) on my two XML files:
<?php
$files = array('employee1.xml', 'employee2.xml');
$xpathQuery = '/employees/employee[name="Jane"]';
$count = 0;
foreach ($files as $file) {
$xml = simplexml_load_file($file);
$result = $xml->xpath($xpathQuery);
if (count($result) > 0) {
$count++;
}
}
if ($count > 1) {
echo "Duplicates for Jane";
} else {
echo "No duplicates for Jane";
}
?>
Instead of searching for duplicates of the employee Jane like above, I would like the script to search for all duplicates on the two XML files. This would require extracting each value from the two XML files and using the loop above it should search if a value exist on both XML files. If the same name exist on both employee1.xml and employee2.xml, the results of this would be added to a third XML file called duplicates.xml
Is this possible? Thanks in advance