I want to compare two xml files in PHP, one file contains customers data(customerdata.xml) another contains rule(rule.xml) which is used to filter customer data, and want to get filtered data of customers(result.xml)
customerdata.xml
<customerdata>
<firstname>allen</firstname>
<lastname>peter</lastname>
<age>21</age>
<country>NL</country>
<firstname>alby</firstname>
<lastname>jerry</lastname>
<age>31</age>
<country>IN</country>
<firstname>thomas</firstname>
<lastname>alfred</lastname>
<age>28</age>
<country>NL</country>
<firstname>ajay</firstname>
<lastname>raghav</lastname>
<age>21</age>
<country>IN</country>
</customerdata>
this is the xml file of customer details. I want to filter these details against some rule contains in another xml file(rule.xml)
rule.xml
<rule>
<ruleoperator>contains</ruleoperator>
<rulevalue>IN</rulevalue>
</rule>
this is my rule xml. After filtering I want to get result as xml(result.xml)
result.xml
<result>
<firstname>alby</firstname>
<lastname>jerry</lastname>
<age>31</age>
<country>IN</country>
<firstname>ajay</firstname>
<lastname>raghav</lastname>
<age>21</age>
<country>IN</country>
<result>
I dont know how to filter this, please help me.