views:

1378

answers:

2

Is it possible for me to create and destroy a TXMLDocument by myself in Borland C++ Builder? I've tried but borland keeps telling me that TXMLDocument is (and must be) an IDE managed component... Also, the only reason that I want to do this is that TXMLDocument sort of crashes: I get the TXMLDocument and 'Gets' a workbook from it, sets some document properties (the xml is saved as an Excel-file later), and the I add some styles... Ok, then I add a worksheet and then all the cells that I want with propper formating and then I save it... At this point everyting is OK. Then I want to save another Excel-file... Since the IDE dosen't let me delete and recreate the TXMLDocument I try to delete just the worksheet form it. When I try this (in debug mode) the IDE goes in to line step mode in the CPU tab (showing some assembler):

ntdll.DbgBreakPoint:
77A07DFE CC               int 3
77A07DFF C3               ret

Any help with this is much appreciated.

+2  A: 

You need to do something like this instead:

_di_IXMLDocument Doc = NewXMLDocument();

I can't remember the gory details of why, but that should point you in the right direction.

There's more info on the Codegear website here.

Roddy
Oookay... Not quite sure what I would do with a _di_IXMLDocument... It seems to be a whole other type of object from TXMLDocument?
c0m4
It is an interface type. And as the article says, the class behaves as a reference-counted interface when you specify a null owner for the TXMLDocument component.
Rob Kennedy
A: 

Try this :

#include <oxmldom.hpp>
#include <XMLDoc.hpp>
#include <xmldom.hpp>
#include <XMLIntf.hpp>


  try
  {
   CoInitialize(0);
   _di_IXMLDocument xmlDoc;
    xmlDoc = LoadXMLData( s1 );
   s1 = xmlDoc->XML->Text;
   CoUninitialize();
   mylog( Fun + String::Format( "ANSW-MSG-XML %s ", ARRAYOFCONST(( s1 ))));
  }
  catch ( Exception & ex )
  {
   mylog( Fun + String::Format( "PARSEXML:ERRORE %s \nmsg:%s",
      ARRAYOFCONST(( ex.Message, cmdMsg ))));
  }
enzo2