trichview.com Forum Index trichview.com
TRichView support forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[RvXML] How to save several documents in one XML file

 
Post new topic   Reply to topic    trichview.com Forum Index -> Examples, Demos
View previous topic :: View next topic  
Author Message
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6576

PostPosted: Tue Sep 06, 2005 5:23 pm    Post subject: [RvXML] How to save several documents in one XML file Reply with quote

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
View user's profile Send private message Visit poster's website
Guest






PostPosted: Wed Sep 07, 2005 5:02 pm    Post subject: Reply with quote

Prety Very Happy
Back to top
an aprendiz
Guest





PostPosted: Thu Sep 08, 2005 7:20 pm    Post subject: Donīt you have a demo towork, with XML Stream and Indy? Reply with quote

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

PostPosted: Fri Sep 09, 2005 7:21 pm    Post subject: Reply with quote

RichViewXML can be found here: http://www.trichview.com/resources/xml
Back to top
View user's profile Send private message Visit poster's website
guest
Guest





PostPosted: Thu Oct 27, 2005 4:41 am    Post subject: Use XML Reply with quote

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

PostPosted: Thu Oct 27, 2005 9:23 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Guest






PostPosted: Thu Oct 27, 2005 10:59 pm    Post subject: Reply with quote

well ..

then how i can save the content of one rv
to an xml stream. almost someting smoot ?
Back to top
Guest






PostPosted: Thu Oct 27, 2005 11:01 pm    Post subject: Reply with quote

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

PostPosted: Fri Oct 28, 2005 12:25 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Guest






PostPosted: Sat Oct 29, 2005 12:47 am    Post subject: Reply with quote

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

PostPosted: Sat Oct 29, 2005 11:31 am    Post subject: Reply with quote

RvXML.SaveToStream
Back to top
View user's profile Send private message Visit poster's website
bob s
Guest





PostPosted: Sat Nov 26, 2005 1:28 am    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    trichview.com Forum Index -> Examples, Demos All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group