Board index » cppbuilder » Problems using TXMLDocument

Problems using TXMLDocument


2005-02-24 04:13:37 AM
cppbuilder55
Hi,
The code below belongs to a unit call Child.cpp, the Child.obj file is used
with others to create a DLL. I used the same piece of code in a single
application to test it and it worked well, but when I have an application
that uses the DLL I'm having the following error at the sentence "
XMLDocument->LoadFromFile((WideString)FileName);"
The error message is : "Exception EOleException in module xmlrtl60.bpl at
00082831"
And the code is :
void TChildFRM::ReadXMLFile(AnsiString FileName, XMLFileDescription
*FileDesc[])
{
int i;
AnsiString NodeName;
AnsiString Value;
_di_IXMLNode docRoot;
_di_IXMLNode docCurrentNode;
XMLDocument = new TXMLDocument("");
ParentNode.clear();
if(FileExists(FileName))
{
XMLDocument->LoadFromFile((WideString)FileName);
docRoot = XMLDocument->DocumentElement;
docCurrentNode = docRoot;
ParentNode[FileDesc[0]->GetNodeLevel()] = docCurrentNode;
Any ideas?
Thank you
Carlos
 
 

Re:Problems using TXMLDocument

"Carlos Botto" < XXXX@XXXXX.COM >wrote in message
Quote
The error message is : "Exception EOleException in module
xmlrtl60.bpl at 00082831"
Is that the whole message? There should have been a text message included
that described the reason for the error.
Quote
XMLDocument = new TXMLDocument("");
Do not use TXMLDocument dynamically like that. TXMLDocument works
differently when instantiated dynamically. Use the IXMLDocument interface
via NewXMLDocument() and LoadXMLDocument() instead, ie:
void TChildFRM::ReadXMLFile(AnsiString FileName, XMLFileDescription
*FileDesc[])
{
_di_IXMLDocument XMLDocument;
//...
if( FileExists(FileName) )
{
XMLDocument = LoadXMLDocument(FileName);
//...
}
else
{
XMLDocument = NewXMLDocument();
//...
}
}
Gambit
 

Re:Problems using TXMLDocument

Remy,
Thank for your answer.
Yes this is the whole error message. The error window title is "Application
error".
I still have the error.
I had another problem linking the DLL, I got some "unresolved external"
errors:
[Linker Error] Unresolved external '__fastcall
Xmldoc::TXMLDocument::LoadFromFile(const System::WideString)' referenced
from Z:\GRAPH ENVIRONMENT\OBJECT\CHILD.OBJ
[Linker Error] Unresolved external '__fastcall
Xmldoc::TXMLDocument::GetDocumentElement()' referenced from Z:\GRAPH
ENVIRONMENT\OBJECT\CHILD.OBJ
[Linker Error] Unresolved external 'Xmldoc::TXMLDocument::' referenced from
Z:\GRAPH ENVIRONMENT\OBJECT\CHILD.OBJ
But I saw in another post that the solution for that was checking "Build
with runtime packages" in Options. Is that correct?
I have the feeling that both problems are related.
Thanks again
Carlos
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Carlos Botto" < XXXX@XXXXX.COM >wrote in message
news:421ce3f0$ XXXX@XXXXX.COM ...

>The error message is : "Exception EOleException in module
>xmlrtl60.bpl at 00082831"

Is that the whole message? There should have been a text message included
that described the reason for the error.

>XMLDocument = new TXMLDocument("");

Do not use TXMLDocument dynamically like that. TXMLDocument works
differently when instantiated dynamically. Use the IXMLDocument interface
via NewXMLDocument() and LoadXMLDocument() instead, ie:

void TChildFRM::ReadXMLFile(AnsiString FileName, XMLFileDescription
*FileDesc[])
{
_di_IXMLDocument XMLDocument;
//...
if( FileExists(FileName) )
{
XMLDocument = LoadXMLDocument(FileName);
//...
}
else
{
XMLDocument = NewXMLDocument();
//...
}
}


Gambit


 

{smallsort}

Re:Problems using TXMLDocument

"Carlos Botto" < XXXX@XXXXX.COM >wrote in message
Quote
I had another problem linking the DLL, I got some
"unresolved external" errors:
You did not make the changes I suggested. Those errors are still
referencing to TXMLDocument.
Quote
But I saw in another post that the solution for that was
checking "Build with runtime packages" in Options. Is
that correct?
If you do that, you will have to distribute additional BPL files along with
your DLL. It sounds like you did not add the xmlrtl package to your
project at all. That would account for the "unresolved external" errors.
Gambit
 

Re:Problems using TXMLDocument

Remy,
Sorry, I didn,t express myself very well. I tried your suggestions, but it
diddn't work either. I'm now back to my original code wich use a
TXMLDocument component, but in any way that I tried to implement it I always
had problems running the application that uses the DLL. It's always the same
error, that why I think it's related to my original problems linking the
DLL.
This is my first implementaion of XML with c++, can you suggest me some
document to read where I can dive for this solutions?
Thank you again
Carlos
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Carlos Botto" < XXXX@XXXXX.COM >wrote in message
news:421cf9a4$ XXXX@XXXXX.COM ...

>I had another problem linking the DLL, I got some
>"unresolved external" errors:

You did not make the changes I suggested. Those errors are still
referencing to TXMLDocument.

>But I saw in another post that the solution for that was
>checking "Build with runtime packages" in Options. Is
>that correct?

If you do that, you will have to distribute additional BPL files along
with
your DLL. It sounds like you did not add the xmlrtl package to your
project at all. That would account for the "unresolved external" errors.


Gambit


 

Re:Problems using TXMLDocument

Remy,
My actual code is:
TXMLDocument *XMLDocument; //I'd drop the component on the Child form, wich
is a fsMDIChild.
void TChildFRM::ReadXMLFile(AnsiString FileName, XMLFileDescription
*FileDesc[])
{
int i;
AnsiString NodeName;
AnsiString Value;
_di_IXMLNode docRoot;
_di_IXMLNode docCurrentNode;
ParentNode.clear();
if(FileExists(FileName))
{
XMLDocument->LoadFromFile((WideString)FileName);
docRoot = XMLDocument->DocumentElement;
docCurrentNode = docRoot;
ParentNode[FileDesc[0]->GetNodeLevel()] = docCurrentNode;
Thanks
Carlos
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Carlos Botto" < XXXX@XXXXX.COM >wrote in message
news:421cf9a4$ XXXX@XXXXX.COM ...

>I had another problem linking the DLL, I got some
>"unresolved external" errors:

You did not make the changes I suggested. Those errors are still
referencing to TXMLDocument.

>But I saw in another post that the solution for that was
>checking "Build with runtime packages" in Options. Is
>that correct?

If you do that, you will have to distribute additional BPL files along
with
your DLL. It sounds like you did not add the xmlrtl package to your
project at all. That would account for the "unresolved external" errors.


Gambit


 

Re:Problems using TXMLDocument

"Carlos Botto" < XXXX@XXXXX.COM >wrote in message
Quote
Sorry, I didn,t express myself very well. I tried your
suggestions, but it diddn't work either.
Why not? Just saying it doesn't work says nothing about the actual problem
you are having. Always provide specific details.
Quote
I'm now back to my original code wich use a TXMLDocument component,
As I already said earlier, you really should not create TXMLDocument
instances dynamically.
Quote
but in any way that I tried to implement it I always had problems
running the application that uses the DLL.
Why? Again, always provide SPECIFIC details.
Gambit
 

Re:Problems using TXMLDocument

Remy,
I implemented your suggestions and I got the same error than with my
original code.
This code is in the Child.cpp unit and the call to this method is in
View.cpp, both units are used to build the DLL.
With your suggestion I had:
void TChildFRM::ReadXMLFile(AnsiString FileName, XMLFileDescription
*FileDesc[])
{
int i;
AnsiString NodeName;
AnsiString Value;
_di_IXMLNode docRoot;
_di_IXMLNode docCurrentNode;
_di_IXMLDocument XMLDocument;
ParentNode.clear();
if(FileExists(FileName))
{
XMLDocument = LoadXMLDocument((WideString)FileName);
docRoot = XMLDocument->DocumentElement;
docCurrentNode = docRoot;
ParentNode[FileDesc[0]->GetNodeLevel()] = docCurrentNode;
And the error "Exception EOleException in module xmlrtl60.bpl at
00082831" occurred at the LoadXMLFile sentence (the FileName variable has
the rigth value). The error window title is "Application Error" and there is
no more information about it
With my original code:
void TChildFRM::ReadXMLFile(AnsiString FileName, XMLFileDescription
*FileDesc[])
{
int i;
AnsiString NodeName;
AnsiString Value;
_di_IXMLNode docRoot;
_di_IXMLNode docCurrentNode;
ParentNode.clear();
if(FileExists(FileName))
{
XMLDocument->LoadFromFile((WideString)FileName);
docRoot = XMLDocument->DocumentElement;
docCurrentNode = docRoot;
ParentNode[FileDesc[0]->GetNodeLevel()] = docCurrentNode;
I got exactly the same error at the LoadFromFile sentence.
Also when I uncheck the ""Build with runtime packages option" I get the
following error when links the DLL:
With your code :
[Linker Error] Unresolved external '__fastcall Xmldoc::LoadXMLDocument(const
System::WideString)' referenced from Z:\GRAPH ENVIRONMENT\OBJECT\CHILD.OBJ
With my code:
[Linker Error] Unresolved external '__fastcall
Xmldoc::TXMLDocument::LoadFromFile(const System::WideString)' referenced
from Z:\GRAPH ENVIRONMENT\OBJECT\CHILD.OBJ
[Linker Error] Unresolved external '__fastcall
Xmldoc::TXMLDocument::GetDocumentElement()' referenced from Z:\GRAPH
ENVIRONMENT\OBJECT\CHILD.OBJ
[Linker Error] Unresolved external 'Xmldoc::TXMLDocument::' referenced from
Z:\GRAPH ENVIRONMENT\OBJECT\CHILD.OBJ
In Desing Packages I have installed the xmldocBCB6.bpl package, and I tried
to install xmlrtl60.bpl, but it complains saying: "Package
c:\Windows\System32\xmlrtl60.bpl can't be installed because it is not a
design time package." Are there any othe package that I should install?
Thank you
Carlos
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Carlos Botto" < XXXX@XXXXX.COM >wrote in message
news:421d116d$ XXXX@XXXXX.COM ...

>Sorry, I didn,t express myself very well. I tried your
>suggestions, but it diddn't work either.

Why not? Just saying it doesn't work says nothing about the actual
problem
you are having. Always provide specific details.

>I'm now back to my original code wich use a TXMLDocument component,

As I already said earlier, you really should not create TXMLDocument
instances dynamically.

>but in any way that I tried to implement it I always had problems
>running the application that uses the DLL.

Why? Again, always provide SPECIFIC details.


Gambit


 

Re:Problems using TXMLDocument

"Carlos Botto" < XXXX@XXXXX.COM >wrote in message
Quote
And the error "Exception EOleException in module xmlrtl60.bpl
at 00082831" occurred at the LoadXMLFile sentence (the FileName
variable has the rigth value). The error window title is "Application
Error" and there is no more information about it
Have you tried running the DLL through the de{*word*81} to find out the exact
exception message? EOleException should be providing a text message
describing the reason for the exception, which the popup message is
problebly stripping off.
The only other thing I can think of is whether your DLL and/or application
ever called CoInitialize() before loading and accessing the XMLDocument. By
default, IXMLDocument uses the MSXML engine, when uses COM, so COM has to be
initialized before MSXML can be used.
Quote
Also when I uncheck the ""Build with runtime packages option"
I get the following error when links the DLL:
You never said whether you are adding the xmlrtl package to your project. I
asked you about that earlier.
Gambit
 

Re:Problems using TXMLDocument

Remy,
Thanks for your help, the solution to the problem was the call to
CoInitialized().
Thanks again
Carlos
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Carlos Botto" < XXXX@XXXXX.COM >wrote in message
news:421e3257$ XXXX@XXXXX.COM ...

>And the error "Exception EOleException in module xmlrtl60.bpl
>at 00082831" occurred at the LoadXMLFile sentence (the FileName
>variable has the rigth value). The error window title is "Application
>Error" and there is no more information about it

Have you tried running the DLL through the de{*word*81} to find out the exact
exception message? EOleException should be providing a text message
describing the reason for the exception, which the popup message is
problebly stripping off.

The only other thing I can think of is whether your DLL and/or application
ever called CoInitialize() before loading and accessing the XMLDocument.
By
default, IXMLDocument uses the MSXML engine, when uses COM, so COM has to
be
initialized before MSXML can be used.

>Also when I uncheck the ""Build with runtime packages option"
>I get the following error when links the DLL:

You never said whether you are adding the xmlrtl package to your project.
I
asked you about that earlier.


Gambit