Recent

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

krzynio

  • Jr. Member
  • **
  • Posts: 81
    • Krzynio's home page
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?
Debian Testing x64 with XFCE 4.14 - Lazarus trunk, FPC 3.0.4
Windows 10 x64 - Lazarus 2.0.10, FPC 3.2.0

lucamar

  • Hero Member
  • *****
  • Posts: 3079
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.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

krzynio

  • Jr. Member
  • **
  • Posts: 81
    • Krzynio's home page
Re: Copy content of TXMLDocument into TMemo
« Reply #2 on: February 18, 2020, 02:48:18 pm »
Thanx!
Debian Testing x64 with XFCE 4.14 - Lazarus trunk, FPC 3.0.4
Windows 10 x64 - Lazarus 2.0.10, FPC 3.2.0

 

TinyPortal © 2005-2018