I’ve just installed Delphi 7 for Personal Use and I’m trying to convert a delphi ClientDataSet file to dfXMLUTF8. All I really need is the xml structure. This site suggests that running 4 lines of code will generate the output I desire. Note however that My file is .cds, not .dat as in the example. I don’t know if this makes a difference.
ClientDataSet1.Active := false;
ClientDataSet1.CreateDataSet;
ClientDataSet1.LoadFromFile('MyBinaryFile.dat');
ClientDataSet1.SaveToFile('MyXMLFile.XML', dfXMLUTF8);
I’m receiving errors and since I’ve never really used Delphi before and I’m hoping somebody who knows what they are doing could just post the very short xml structure for me. Here’s the file(486 bytes) I’m working with. I will award correct answer to the first poster with full dfXMLUTF8 output. Thanks!
Update:
Okay I just started the project from scratch and I think I have it somewhat setup. I have added uses DBClient;, var ClientDataSet1: TClientDataSet, and lastly the procedure:
ClientDataSet1.LoadFromFile('C:\Documents and Settings\XPMUser\Desktop\DelphiCDS\Master.cds');
ClientDataSet1.SaveToFile('C:\Documents and Settings\XPMUser\Desktop\DelphiCDS\output.XML', dfXMLUTF8);
It throws the following error:
Access violation at address 004588B6 in module ‘Project.exe’. Read of
address 00000000.
Update2:
Here’s what I ended up with:
unit Script3;
interface
uses
Forms, DBClient;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
end;
var
Form1: TForm1;
CDS: TClientDataSet;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
CDS := TClientDataSet.Create(nil);
try
CDS.LoadFromFile('.\input.cds');
CDS.SaveToFile('.\output.xml', dfXMLUTF8);
finally
CDS.Free;
end;
end;
end.
You’re doing much more than you have to in order to accomplish the conversion. With the presumption that
MyBinaryFile.datis actually a binary format DelphiTClientDataSetfile, these two lines of code (with no additional setup) will work:Without knowing more about what your
MyBinaryFile.datis, and no information about the errors you’re getting, it’s pretty difficult to provide more information. Tested and working with the standardanimals.cdsin Delphi 7 (fromC:\Program Files\Common Files\Borland Shared\Datain a standard D7 install on a Windowx XP virtual machine).It seems, from your comment below, that the actual problem you’re having is a compiler error about an unidentified identifier
TClientDataSetwhen you try and create it in code. If you have a high enough SKU for Delphi 7 that includesTClientDataSet(IIRC, Professional and higher), you can just addDBClientto your uses clause:Or, better yet, if you’re creating a VCL Forms application, just drop a
TClientDataSeton your form; you’ll find it on theDataAccesstab in the component palette.