Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: So Jul 13, 2025 17:10

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 4 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: object to xml howto?
BeitragVerfasst: Di Sep 26, 2006 21:30 
Offline
DGL Member
Benutzeravatar

Registriert: Di Jul 01, 2003 18:59
Beiträge: 887
Wohnort: (The Netherlands)
Programmiersprache: fpc/delphi/java/c#
How do i convert an object to xml data?
I think of using a TRemotable descendant, but i do not understand on how to use the ObjectToSoap function. I think i should use it together with TXmlDocument, but how? Or am i going the hard way? I do not want to use third party components as i want to use turbo delphi.

Also i could use some info serializing objects in delphi e.g. how do i write my own serializing function? E.g. serialize to xml or even fancier to an sql query.... but first i need to learn the basics.... any tutorials on this topic?

Thanks in advance.

_________________
http://3das.noeska.com - create adventure games without programming


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Sep 27, 2006 16:09 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Mai 14, 2004 18:56
Beiträge: 804
Wohnort: GER/OBB/TÖL-WOR/Greiling
The RTTI is able to serialize components, unfortunately not to XML. But to binary dfm and text dfm. And text dfm is a usable format, I'd think.

You only need to derive your classes from TComponent and pack everything you want to have saved into published properties.

You can then do it like this:

Code:
  1.  
  2. procedure Save(var data: TStream);
  3. begin
  4. if not assigned(data) then data := TMemoryStream.Create;
  5.  
  6. data.WriteComponent(someMyComponent);
  7. end;
  8.  
  9. function Load(data: TStream): TMyComponent;
  10. begin
  11.   Result := TMyComponent.Create(whereever_or_nil);
  12.   data.ReadComponent(Result);
  13. end;
  14.  


This works in principle, but I myself am currently fighting with it and just can't get it to work. However, I have a rather complicated structure.

_________________
Bild

"User Error. Replace User and hit Continue."


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Sep 27, 2006 18:55 
Offline
DGL Member
Benutzeravatar

Registriert: Di Jul 01, 2003 18:59
Beiträge: 887
Wohnort: (The Netherlands)
Programmiersprache: fpc/delphi/java/c#
Using google again i found: http://www.delphipages.com/threads/thre ... 4&G=116542 this seems to do what i want, all i have to learn it is object inside object and list and arrays.

_________________
http://3das.noeska.com - create adventure games without programming


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Fr Sep 29, 2006 14:58 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Mai 14, 2004 18:56
Beiträge: 804
Wohnort: GER/OBB/TÖL-WOR/Greiling
*whistle*

Looks like something great! Seems like you helped me more than I did you ;)

_________________
Bild

"User Error. Replace User and hit Continue."


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 4 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.007s | 16 Queries | GZIP : On ]