BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

XML-novice needs advice

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Staffan.Bergbom@lm.se
Guest





PostPosted: Tue Feb 15, 2005 12:41 pm    Post subject: XML-novice needs advice Reply with quote



I'm all new to using TXMLDocument and have, for a document, built a
xdb-fil and corresponding pas-fil using the Data Binding Wizard.

I worked well to retrieve and update data when using property
XMLDocument1.FileName but I get an error when I try to use method
XMLDocument1.LoadFromStream.

I'm trying to make an app read streamed-xlmdata over a socket and
then reading this stream into the XMLDocument using LoadFromStream.

The code below shows how I try to do this

try
xmlStream := TMemoryStream.Create;
with AThread.Connection do
begin
size := AThread.Connection.ReadInteger;
xmlStream.SetSize(size);
AThread.Connection.ReadStream(xmlStream, size);
xmlStream.Position := 0;
xml.LoadFromStream(xmlStream);
{ i := 0;
while i < size do
begin
xmlStream.Read(tkn , 1);
xml := xml + tkn;

i := i + 1;
end; }
XMLDocument1.LoadFromXML(xml.Text);
FLuppXchange := GetLuppXchange(XMLDocument1);
XMLDocument1.SaveToFile('test.xml');
end;
finally
FreeAndNil(xmlStream);
FreeAndNil(xml);
end;

The error I get is: "CoInitialize not called"
I guess that is because I haven't specified what xdb-file to use
but how do I do that.

Regards
Staffan

Back to top
Markku Nevalainen
Guest





PostPosted: Tue Feb 15, 2005 1:27 pm    Post subject: Re: XML-novice needs advice Reply with quote



[email]Staffan.Bergbom (AT) lm (DOT) se[/email] wrote:
Quote:

The error I get is: "CoInitialize not called"
I guess that is because I haven't specified what xdb-file to use
but how do I do that.

TXMLDocument calls MSXML.DLL, then there's some COM confilict, or
something...
I don't know, or can't explain it more in specific. But try adding this
Unit to your project:

unit ComInit;

interface

uses
ActiveX;

implementation

initialization
CoInitialize(nil); // Or maybe also:
CoInitializeEx(nil,COINIT_MULTITHREADED);

finalization
CoUninitialize;
end.


When I added that Unit to my MainForm's Uses section as the first unit
in the list, those CoInitialize messages disappeared. That time I was
using TExcel and TMsWord components, not TXMLDocuments. But the problem
probably has (may have) the same nature.

Markku Nevalainen

Back to top
patoche
Guest





PostPosted: Wed Feb 16, 2005 10:11 am    Post subject: Re: XML-novice needs advice Reply with quote



Hi,

Inspite the delphi Xml object has probably been created, its underlying
COM object has not.
Have correctly initialized the xml object ?

if it's a "visual" component placed on a form it should have its
autoconnect property set to true. If not, you first have to create it
and then connect it.

This is because the delphi xml object are wrappers of the Ms Com
object.

Must be something in that direction

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc 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, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.