i have some xml files as follows-
<?xml version="1.0"?>
<contacts>
<contact>
<mobile_no>9829344744</mobile_no>
<name>Sample Name 1</name>
<email>Some Email</email>
</contact>
<contact>
<mobile_no>9829344799</mobile_no>
<name>Sample Name 2</name>
<email>Some Email</email>
</contact>
<contact>
<mobile_no>9829345035</mobile_no>
<name>Sample Name 3</name>
<email>Some Email</email>
</contact>
</contacts>
i have two xml files in above format. each file has distinct <mobile_no>
but i want to extract distinct <mobile_no>
from both files.
i have tried and use following code of php
$arr_filename[] = "file1.xml";
$arr_filename[] = "file2.xml";
$arr_contact = array();
foreach($arr_filename as $filename)
{
$xml = new simpleXMLElement($filename, null, true);
$contact_array1 = $xml->xpath('contact/mobile_no');
for($i=0; $i<count($contact_array1); $i++)
{
$arr_contact[$contact_array1[$i]]=true;
}
}
i found array $arr_contact
with distinct contact no as its key
its working fine but problem is that when files has large content(records) and use more files (approximately 10) it takes too much time to process. i want to get more efficient method to extract distinct mobile no from more than one xml files. just as we extract distinct from more than one table in mysql.