Recent

Author Topic: Copy content of TXMLDocument into TMemo  (Read 226 times)

krzynio

  • Jr. Member
  • **
  • Posts: 76
Copy content of TXMLDocument into TMemo
« on: January 29, 2020, 11:39:23 am »
Hello!
To copy my XML document into memo I use such code
Code: Pascal  [Select]
  1.     st := TStringStream.Create('');
  2.     WriteXMLFile( Doc, st);
  3.     st.Position := 0;
  4.     memo.Lines.LoadFromStream(st);
  5.     st.Free
  6.  
but I fill that there must be more simple method like
Code: Pascal  [Select]
  1. memo.Lines.Text := XMLDoc.TextContents
  2.  
or something similar.
Can you help, please?
Lazarus version: trunk. FPC version: 3.0.4. OS: Linux Debian Testing x64 with XFCE 4.12 and Windows 10 x64 version: 1709

lucamar

  • Hero Member
  • *****
  • Posts: 2403
Re: Copy content of TXMLDocument into TMemo
« Reply #1 on: January 29, 2020, 03:25:35 pm »
AFAICT, there is no simpler way to do it. You could always add that code inside a class helper, if you use it in many places.

If you do, you should make it general enough that the XML can be loaded from/saved to any TStrings descendant.

HTH
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.4/2.0.6  - FPC 3.0.4 on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

krzynio

  • Jr. Member
  • **
  • Posts: 76
Re: Copy content of TXMLDocument into TMemo
« Reply #2 on: February 18, 2020, 02:48:18 pm »
Thanx!
Lazarus version: trunk. FPC version: 3.0.4. OS: Linux Debian Testing x64 with XFCE 4.12 and Windows 10 x64 version: 1709