Replace the xml string templates from database dynamically [duplicate]

I have a request that has been stored in the database. when I execute this request

    $sql ="SELECT * FROM `route` WHERE `company` ='SHOFCO'";
    $result = compute::instance()->fetch($sql,false,true);
    $xml = $result['requestTemplate'];

It will return

    $xml ="<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mob="urn:microsoft-dynamics-schemas/codeunit/Mobile_Solutions">
   <soapenv:Header/>
   <soapenv:Body>
      <mob:InsertPaybill>
         <mob:refnumber>$MpesaReceiptNumber</mob:refnumber>
         <mob:pdate>$TransTime</mob:pdate>
         <mob:descriptions>$FullNames</mob:descriptions>
         <mob:amount>$Amount</mob:amount>
         <mob:accountNumber>$PhoneNumber</mob:accountNumber>
         <mob:transactionDate>$TransTime</mob:transactionDate>
         <mob:transactionDescription>$FullNames</mob:transactionDescription>
         <mob:paybillnumber>$PayBillNumber</mob:paybillnumber>
         <mob:referenceNumber>$AccountReference</mob:referenceNumber>
      </mob:InsertPaybill>
   </soapenv:Body>
</soapenv:Envelope>";

Now I want the vairable in the string $MpesaReceiptNumber,$TransTime,FullNames etc to be replaces with the actual values stored in the below varibles.

$MpesaReceiptNumber ="RDT6AZ26DK";
$FullNames ="TEST ALEX";
$TransTime ="2023-04-29";
$Amount ="1";
$PhoneNumber ="0704722837";
$PayBillNumber ="4012913";
$AccountReference ="12345";

Here is my full code

$MpesaReceiptNumber ="RDT6AZ26DK";
$FullNames ="TEST ALEX";
$TransTime ="2023-04-29";
$Amount ="1";
$PhoneNumber ="0704722837";
$PayBillNumber ="4012913";
$AccountReference ="12345";

$sql ="SELECT * FROM `route` WHERE `company` ='SHOFCO'";
$result = compute::instance()->fetch($sql,false,true);
$xml = $result['requestTemplate'];

echo $xml;

When I run my code it just echo without replacing the varibales.