I want to add excel file data into an existing XML file and a particular tag.
I want to add excel data of upc code into the upc tag of the XML file using PHP.
My excel file format is:
I want the following XML format data.
I want to add excel file data into an existing XML file and a particular tag.
I want to add excel data of upc code into the upc tag of the XML file using PHP.
My excel file format is:
I want the following XML format data.
$xml = simplexml_load_file("yourxmlfilename.xml");
$prod = $xml->Products;
print_r($prod->Product->count());
for($i=1; $i<=$prod->Product->count();$i++){
$str = (string) $prod->Product[$i]->ExternalId;
if($str == 'mobilesn1'){
$c = $prod->Product[$i]->UPCs;
print_r($prod->Product[$i]->UPCs->UPC);
if((string)$prod->Product[$i]->UPCs->UPC !="895623" ){
//unset($prod->Product[$i]->UPCs->UPC);
$c->addChild('UPC', '895623');
$xml->asXML("yourxmlfilename.xml");
}
}
}