response-xml icon indicating copy to clipboard operation
response-xml copied to clipboard

How to add encoding and other attributes to the generated XML tag response

Open emekaadirije opened this issue 4 years ago • 1 comments

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.

emekaadirije avatar Jul 15 '20 17:07 emekaadirije

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);

ChristofK avatar Jul 16 '20 20:07 ChristofK