 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Staffan.Bergbom@lm.se Guest
|
Posted: Tue Feb 15, 2005 12:41 pm Post subject: XML-novice needs advice |
|
|
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
|
Posted: Tue Feb 15, 2005 1:27 pm Post subject: Re: XML-novice needs advice |
|
|
[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
|
Posted: Wed Feb 16, 2005 10:11 am Post subject: Re: XML-novice needs advice |
|
|
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 |
|
 |
|
|
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
|
|