I'm having trouble creating a XML document with a CDATA section. Given this code:
const xmlObj = {
"s:Envelope": {
'@xmlns:s': http://schemas.xmlsoap.org/soap/envelope/",
"s:Body": {
"DoStuff": {
'@xmlns': "https://randomUrl",
'XmlRequest': {
'$': {
'test': 'apples'
}
}
}
}
}
}
const final = xmlBuilder.create(xmlObj).end({ prettyPrint: true});
return final;
What I get is this:
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<DoStuff xmlns="https://randomUrl">
<XmlRequest><![CDATA[[object Object]]]></XmlRequest>
</DoStuff>
</s:Body>
</s:Envelope>
I'd like it to be like this:
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<DoStuff xmlns="https://randomUrl">
<XmlRequest>
<![CDATA[<test>
apples
</test>]]>
</XmlRequest>
</DoStuff>
</s:Body>
</s:Envelope>
The issue is the [Object object] part