One of the major advantage DD4T 2.0 is producing the rendered output in the JSON format and removing unnecessary tags/data so as to have a smaller payload while publishing.
Although, till meta-version of DD4T 2.0, the output of Templates can be generated in JSON as well as in XML format, however, in the main release this option has been smartly removed and may have very valid reasons behind it.
On the other side, if you are in real need of getting the XML output (of course at the expense of quite good benefits that DD4T 2.0 provides) then you can follow below simple steps:
- Open CME and navigate to the location where all DD4T 2.0 Templates, TBB and Schema have been installed.
- Open the Parameter Schema – Generate dynamic component – to edit
- Add a new Field of type Text with xml name as SerializationFormat. Also configure this field to select its value from a List with the list have two values – JSON, XML.
The below image depicts this:
- Now open the Component Template for which you want to render the output in the XML Format in the Template Builder tool to edit
- Once in Template Builder, select the Template Building Block (TBB) – Generate dynamic component
- Change the parameter value for this newly added field – SerializationFormat – as XML and “Save & Close” the template. Below screen shot illustrates this:
- That’s it – you are done and now the output of this specific template will be generated in XML format.
Note: If no value is selected for the parameter – SerializationFormat – then by default the output will be rendered in JSON format.