I'm building my request data as an array structure and want to use the symfony XmlEncoder to encode my Array to XML.
I guess I got the fundamental part right, it looks like that for example:
$request_object = [
"acc-id" => $all_credentials,
"req-id" => $request_guid,
"tran-type" => "spec-url"
];
The syntax I'm looking for encodes in the following format, with attribute and value:
<amount currency="EUR">1.99</amount>
I have the possibility to use the @ sign on an array key, but how do I also fit in the value?
$request_object = [
"acc-id" => $all_credentials,
"req-id" => $request_guid,
"tran-type" => "spec-url"
"am" => ["@attr"=>"attrval"]
];
This should be:
<am attr="attrval"/>
But how to write it so that I can also set the value? like:
<am attr="attrval">VALUE</am>