My output from JSON to XML is coming out with <?xml version="1.0" encoding="UTF-8"?>. How can I prevent this from happening? I can write a dummy XSLT with omit-xml-declaration="yes". It may or may not work, but I do not want to run a XSLT just for this.
The purpose is - I am creating a child nodeset with this transform. I want to include this child node as-is in my next assign message step to create a SOAP message.
Solved! Go to Solution.
Hi @Nilesh Kumar, the JSON to XML policy by default will output the prolog in the generated XML. An alternative approach is to consider adding an Extract Variable policy right after the JSON to XML Policy & extract the root element minus the prolog.
For eg if the XML document is set in a variable name xmlResponse like this:
<?xml version="1.0" encoding="UTF-8"?> <Name> <First>Joe</First> <Last>Smith</Last> </Name
then an Extract Variable policy like this:
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables"> <DisplayName>Extract Variables</DisplayName> <Properties/> <Source clearPayload="false">xmlResponse</Source> <XMLPayload stopPayloadProcessing="false"> <Namespaces/> <Variable name="newXMLResponse" type="nodeset"> <XPath>//Name</XPath> </Variable> </XMLPayload> </ExtractVariables>
will result in variable newXMLResponse like:
<Name> <First>Joe</First> <Last>Smith</Last> </Name
Hope this helps.