| View previous topic :: View next topic |
| Author |
Message |
Sergey Tkachenko Site Admin
Joined: 27 Aug 2005 Posts: 6576
|
Posted: Tue Sep 06, 2005 5:23 pm Post subject: [RvXML] How to save several documents in one XML file |
|
|
| Code: | uses RichViewXML, RVXMLBase;
RichView1, RichView2 - trichviews to load/save.
RichViewXML1 - trichviewxml.
This example saves and loads two documents in 'd:\1.xml'
// Saving
procedure TForm1.Button1Click(Sender: TObject);
var
T: TXMLTree;
MainRoot, DocRoot: TXMLTag;
begin
T := TXMLTree.Create(RichViewXML1.Encoding);
try
T.BaseFilePath := RichViewXML1.BaseFilePath;
T.Items.AddTag(RichViewXML1.RootElement, T, T);
MainRoot := T.Items[0];
MainRoot.Items.AddTag('document1', T.Items[0], T);
DocRoot := MainRoot.Items[MainRoot.Items.Count-1];
RichViewXML1.RichView := RichView1;
RichViewXML1.SaveToXML(DocRoot);
MainRoot.Items.AddTag('document2', T.Items[0], T);
DocRoot := MainRoot.Items[MainRoot.Items.Count-1];
RichViewXML1.RichView := RichView2;
RichViewXML1.SaveToXML(DocRoot);
T.SaveToFile('d:\1.xml', RichViewXML1.WantTabs);
finally
T.Free;
end;
end;
// Loading
procedure TForm1.Button2Click(Sender: TObject);
var
T: TXMLTree;
MainRoot, DocRoot: TXMLTag;
begin
T := TXMLTree.Create(RichViewXML1.Encoding);
try
T.BaseFilePath := RichViewXML1.BaseFilePath;
T.UnicodeTags.Add('utext');
T.LoadFromFile('d:\1.xml');
RichViewXML1.RichView := RichView1;
MainRoot := T.Items.FindTagOfName(RichViewXML1.RootElement);
if MainRoot<>nil then begin
DocRoot := MainRoot.Items.FindTagOfName('document1');
if DocRoot<>nil then
RichViewXML1.LoadFromXML(DocRoot);
RichViewXML1.RichView := RichView2;
DocRoot := MainRoot.Items.FindTagOfName('document2');
if DocRoot<>nil then
RichViewXML1.LoadFromXML(DocRoot);
end;
finally
T.Free;
end;
RichView1.Format;
RichView2.Format;
end; |
|
|
| Back to top |
|
 |
Guest
|
Posted: Wed Sep 07, 2005 5:02 pm Post subject: |
|
|
Prety  |
|
| Back to top |
|
 |
an aprendiz Guest
|
Posted: Thu Sep 08, 2005 7:20 pm Post subject: Donīt you have a demo towork, with XML Stream and Indy? |
|
|
hello, never I have worked with streams, neither with XML,
nor with components of Internet I have reviewed your demo,
How to save documents in one XML file
sergey, you can put a demo. to be able to send XML streams
using the RichViewXML component and indy IdTcpClient, IdTcpServer
So Thanks |
|
| Back to top |
|
 |
Sergey Tkachenko Site Admin
Joined: 27 Aug 2005 Posts: 6576
|
|
| Back to top |
|
 |
guest Guest
|
Posted: Thu Oct 27, 2005 4:41 am Post subject: Use XML |
|
|
When i use the method SaveToStream from the component
RichViewXML
this are an XML File in stream format ?
or is like the methods SaveToStream, SaveSelecctionToStream.?
or is better use the method SaveRVFToStream?
because i want send rich text using indy.
the text most be retain attributes like font color, font, size. etc |
|
| Back to top |
|
 |
Sergey Tkachenko Site Admin
Joined: 27 Aug 2005 Posts: 6576
|
Posted: Thu Oct 27, 2005 9:23 am Post subject: |
|
|
RVXML.SaveToStream saves absolutely the same information in stream as RVXML.SaveToFile saves to file.
As for XML vs RVF... Generally, RichViewXML's XML and RVF data contain the same information. XML has an advantage that it can be understanded by human, RVF is a computer-oriented format and may contain binary data (if rvfoSaveBinary is excluded from RVFOptions, binary data are saved as hexadecimal numbers, so it still cannot be read by humans). Binary RVF files are usually smaller than the corresponding XML, non-binary may be larger in some cases.
The main disadvantage of RichViewXML - it was not created by me and I can give no guaranties about it quality (I continue to support it, though). All new TRichView features are added to RVF immediately, RichViewXML updates follow with some delay. |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Oct 27, 2005 10:59 pm Post subject: |
|
|
well ..
then how i can save the content of one rv
to an xml stream. almost someting smoot ? |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Oct 27, 2005 11:01 pm Post subject: |
|
|
well ..
then how i can save the content of one rv
to an xml stream. almost someting smoot ? |
|
| Back to top |
|
 |
Sergey Tkachenko Site Admin
Joined: 27 Aug 2005 Posts: 6576
|
Posted: Fri Oct 28, 2005 12:25 pm Post subject: |
|
|
RvXML.SaveToFile('c:\doc.xml') saves TRichView (or TRichViewEdit) assigned to RvXML.RichView.
RichViewXML has documentation as a demo project (documentation in XML files, a viewer is included) |
|
| Back to top |
|
 |
Guest
|
Posted: Sat Oct 29, 2005 12:47 am Post subject: |
|
|
yes i have been that.
first save the content to an xml file then load this
xml file into an richview, then i use savetostream.
but i want do it in memory.
make the convertion directly from
richview o richviewedit to and xml stream
with out save it to xml file in the HD, like you say. |
|
| Back to top |
|
 |
Sergey Tkachenko Site Admin
Joined: 27 Aug 2005 Posts: 6576
|
Posted: Sat Oct 29, 2005 11:31 am Post subject: |
|
|
| RvXML.SaveToStream |
|
| Back to top |
|
 |
bob s Guest
|
Posted: Sat Nov 26, 2005 1:28 am Post subject: |
|
|
| I'm wondering if anyone here has tinkered with using NativeXml from http://www.simdesign.nl/xml.html and TRichview.? Not sure if it be a good idea or not... still learning. |
|
| Back to top |
|
 |
|