Helllo, i want to set the the dynamic value of variable into xml file
try {
$om = \Magento\Framework\App\ObjectManager::getInstance();
$filesystem = $om->get('Magento\Framework\Filesystem');
$directoryList = $om->get('Magento\Framework\App\Filesystem\DirectoryList');
$media = $filesystem->getDirectoryWrite($directoryList::MEDIA);
$contents = '<?xml version="1.0" encoding="utf-8"?>
<TESTORDER>
<TESTINFO>
<SHIPADDRESS>
<NAME>{{var shipping_firstname}} {{var shipping_lastname}}</NAME>
<ADDRESS1>{{var shipping_company}}</ADDRESS1>
<ADDRESS2>{{var order.getShippingAddress().getStreet(1)}}</ADDRESS2>
<ADDRESS3>{{var order.getShippingAddress().getStreet(2)}}</ADDRESS3>
<ADDRESS4></ADDRESS4>
<CITY>{{var shipping_city}}</CITY>
<STATE>{{var order.getShippingAddress().getRegion()}}</STATE>
<ZIP>{{var shipping_postcode}}</ZIP>
<COUNTRY>{{var shipping_country_id}}</COUNTRY>
</SHIPADDRESS>
</TESTINFO>
</TESTORDER>';
$media->writeFile("test/test.xml",$contents);
}
catch(Exception $e){
echo $e->getMessage();
}