Merge two xml files based on common attribute

前端 未结 2 514
忘了有多久
忘了有多久 2021-01-25 00:27

I have two xml files with a similar structure, and I need to merge them based on a common attribute. To be more explicit, here are two samples:

file1.xml



        
2条回答
  •  遇见更好的自我
    2021-01-25 00:50

    You can use the attribute() function of SimpleXML

    $xml = simplexml_load_file($filename);
    foreach($xml->Products->record->attributes() as $attribute => $value) {
        //do something
    }
    

提交回复
热议问题