AdvantageCMS.Core.Common.BaseClasses Namespace
Build With Advantage

ObjectXMLSerializer<(Of <(<'T>)>)>..::..SaveToString Method

Serializes the specified object to an XML string.

Namespace:  AdvantageCMS.Core.Utils
Assembly:  AdvantageCMS.Core (in AdvantageCMS.Core.dll)

Syntax


public static string SaveToString(
	T serializableObject,
	bool useNamespace
)

Parameters

serializableObject
Type: T
The object to serialize.
useNamespace
Type: Boolean
If true, includes XML namespaces in the output; otherwise, omits them.

Return Value

The XML string representation of the object.

Examples


C#
var config = new AppConfig { Name = "MyApp", Version = 2 };

// Serialize without namespaces (default)
string xml = ObjectXMLSerializer<AppConfig>.SaveToString(config);

// Serialize with namespaces
string xmlWithNs = ObjectXMLSerializer<AppConfig>.SaveToString(config, useNamespace: true);

// Round-trip back to object
AppConfig restored = ObjectXMLSerializer<AppConfig>.LoadFromString(xml);