Serializes the given object to XML.

serializeXML( objToBeSerialized, useCustomSerializer ) → returns string

This function requires Adobe ColdFusion 11 and up.  Not supported on Lucee, etc.

Argument Reference

objToBeSerialized any

An object to be serialized.

useCustomSerializer boolean
Default: true

Whether to use the custom serializer. The default value is true. The custom serializer will be always used for XML deserialization. If false, the XML/JSON deserialization will be done using the default ColdFusion behavior. If any other type is passed with useCustomSerializer as false, then TypeNotSupportedException will be thrown.

Sample code invoking the serializeXML function

This will serialize the object to XML using ColdFusion's default serialization mechanism.

serializeXML({ "firstName": "John", "lastName": "Doe" })

Expected Result: <STRUCT ID="1"><ENTRY NAME="lastName" TYPE="STRING">Doe</ENTRY><ENTRY NAME="firstName" TYPE="STRING">John</ENTRY></STRUCT>

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub