Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Thread Tools Display Modes
Old 11-19-2010, 08:25 PM
Bashk Bashk is offline
Senior Member
Join Date: Nov 2001
Posts: 349
Default Add/extract info and file in/from XML

Good evening everibody.
Since I have never used XML in conjunction with Delphi, I can say that I'm a total newbie in this area.
Can anybody help me with some example of how to store the following elements in an XML file (and how to extract them from there):
- file name
- file size
- binary file (some jpg, doc or exe, not a plain file)

Something like this (if you take the content of filecontent and save it in a icon.jpg file you will get exactly the picture:

HTML Code:
<?xml version="1.0" encoding="iso-8859-1"?>
  <filecontent> JFIF  ` `   C 		

 C  % ("            	
    } !1AQa"q2#BR$3br	
   w !1AQaq"2B	#3Rbr
$4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz   ? >#6
&KROO Dܞ OuOzmecO<*F	c=jW⶗O
ZL{sq{oظ%#LFdpGbO>*{E:o6勖3G~69 c
n([X-T]2+bn-qsi,0 mx?oh%5kg\}H%<,WIWˡO	7ouss&Y-:۵G1LCʌk*.R{M_s(,_?
k1*~*o5*^D>_p <ǜ`&#91;&#93;'<?::5&#91;1;$%(I mHW? BypC9D92<l$x'Z_/s>C1m%3	ciQBzp+ $rbjV^JyGR6ѥ<EVzH@vH<xq*
kq"vRK	\
ܝ @Hns' 爾j/t0xBYᶷt Ff6x\z? ?	uo  *`R^"I<ǧ9X\6ZX+Yֲ,&#93;6'(IZ;{~?*h/m 6L$V(ᔎuCI*;Þ4mJCkglcz$I'I$hM(
Thank you very much for your help. Much appreciated!
Reply With Quote
Old 12-03-2010, 12:21 AM
Bashk Bashk is offline
Senior Member
Join Date: Nov 2001
Posts: 349

It seems like working with binary files is a damn hard work. Never worked it out...
So I've decided to convert binary to Base64 prior to store in XML, and convert back to binary when read.
This way I've overcomed many problems.
I will let this thread open just in case somebody will came with a solution to this problem for future questions ...
"If you know your enemies and know yourself, you will not be imperiled in a hundred battles; if you do not know your enemies but do know yourself, you will win one and lose one; if you do not know your enemies nor yourself, you will be imperiled in every single battle." - Sun Tzu (Art of War).
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

All times are GMT. The time now is 02:55 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.