Return XML with attributes

Hello

I’m trying to send back XML in a custom Server side script.

 var contents = platform.api.post( "ourDBservice/_proc/" + params.sp, event.request.payload, options);

 var result = {
     "DocDetail": [{
                 "Name": {"-esign" : "0"} ,
                 
     "Data": contents
     }]
};

Outputs

<?xml version="1.0" ?><dfapi>
        <DocDetail>
                <Name>
                        <-esign>0</-esign>
                </Name>
                <Data>
                        <status_code>200</status_code>
                        <content>

When I need esign to be an attribute of Name

<Name esign="0">Monitoring</Name>

I’m not sure how to escape esign so that its an attribute ?

Any ideas would be greatly appreciated.

Regards, Kieren.

“Prefix attributes with: @
XML attributes will be transformed into regular JSON properties and this prefix will be added to the property name to help differentiate a regular node from an attribute. Leave blank if you do not want a prefix.
text property name:
The name given to the JSON property that reflects a terminal XML #text item type.”
> {
> “family” : [{
> “" : { > "name" : "Johnson" > }, > "child" : [{ > "” : {
> “name” : “John”,
> “age” : “5”
> },
> “toy” : [{
> “" : { > "status" : "old" > }, > "_" : "Trooper" > }, { > "” : {
> “status” : “old”
> },
> “" : “Ultrablock”
> }, {
> “$” : {
> “status” : “new”
> },
> "
” : “Bike”
> }
> ]
> }
> ]
> }
> ]
> }

Converts to

<family name="Johnson">
    <child name="John" age="5">
        <toy status="old">Trooper</toy>
        <toy status="old">Ultrablock</toy>
        <toy status="new">Bike</toy>
    </child>
</family>

Is the conversion of array to XML or JSON with standard PHP or with Server Side scripting V8js or something else in Dreamfactory. Its currently a black box to me, so its difficult to know which path to take.

Preference is to not iterate arrays, or manually serialize to a string and force content type.

Any advice would be appreciated.

As @mimu mentioned in his post,“How to convert XML response of Remote web service to JSON”, I too would be interested in how to implement the following:
“From the 2.1 release notes:
XML to JSON content conversion now handles namespaces (i.e. singular namespaces are used to pull data into JSON format).”

Please advise, kind regards,
Kieren.