Recent

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

krzynio

  • Jr. Member
  • **
  • Posts: 99
    • 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?
Ubuntu 23.10 x64, / Windows 11 PL - latest updates
Lazarus 2.2.6, FPC 3.2.2

lucamar

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

krzynio

  • Jr. Member
  • **
  • Posts: 99
    • Krzynio's home page
Re: Copy content of TXMLDocument into TMemo
« Reply #2 on: February 18, 2020, 02:48:18 pm »
Thanx!
Ubuntu 23.10 x64, / Windows 11 PL - latest updates
Lazarus 2.2.6, FPC 3.2.2

 

TinyPortal © 2005-2018