When you use the TCustomClientDataSet.SaveToFile procedure, you can select the output format; for the default value, this is the dfBinary value, which encodes data in binary format.
procedure TCustomClientDataSet.SaveToFile(const FileName: string = ''; Format: TDataPacketFormat = dfBinary);
try changing the Format parameter to dfXML or dfXMLUTF8
ClientDataSet1.SaveToFile('file.xml',dfXML);
if you want to format the XML output, you can use the FormatXMLData function FormatXMLData try this code
uses XMLDoc; Procedure FormatXMLFile(XmlFile:string); var oXml : TXMLDocument; begin oXml := TXMLDocument.Create(nil); try oXml.LoadFromFile(XmlFile); oXml.XML.Text:=xmlDoc.FormatXMLData(oXml.XML.Text); oXml.Active := true; oXml.SaveToFile(XmlFile); finally oXml := nil; end; end;
finally you will look like this:
ClientDataSet1.SaveToFile('test.xml',dfXML); FormatXMLFile('test.xml');
source share