response-xml
response-xml copied to clipboard
How to add encoding and other attributes to the generated XML tag response
I would like to learn how to add attributes to the XML tag
Currently my response results to the below code
<?xml version="1.0"?>
<Response>
<Param>
<Key>InvoiceNumber</Key>
<Value>988899999</Value>
</Param>
</Response>
I would like to get something like
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<Param>
<Key>InvoiceNumber</Key>
<Value>988899999</Value>
</Param>
</Response>
Any help is appreciated.
try
$xml = <<<XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<Param>
<Key>InvoiceNumber</Key>
<Value>988899999</Value>
</Param>
</Response>
XML;
return response()->xml($xml);