Here is the code that I have to use the XML DOM. You only need the XSD stuff
if you are validatin using a schema definition:

uses
..
MSXML2_TLB
..


procedure LoadFromFile(FileName, XSDFile: String);
var
  doc : IXMLDOMDocument2;
  schemas : IXMLDOMSchemaCollection2;
  perror : IXMLDOMParseError;
begin
  doc := CoDOMDocument40.Create;
  doc.async := False;

  schemas := CoXMLSchemaCache40.Create;
  schemas.add(WideString('http://www.topografix.com/GPX/1/0'),
WideString(XSDFile));
  doc.schemas := schemas;
  if doc.load(FileName) then
    begin
    perror := doc.parseError;
    if Validate and (perror.errorCode <> S_OK) then
      begin
..
      end
    else
        etcc......




----- Original Message ----- 
From: "Allan, Samuel" <[EMAIL PROTECTED]>
To: "NZ Borland Developers Group - Delphi List" <[EMAIL PROTECTED]>
Sent: Wednesday, February 18, 2004 1:26 PM
Subject: [DUG] Error: CoInitialize has not been called


> I am getting an error: CoInitialize has not been called. It happens when
> I call the LoadFromFile method of a TXMLDocument.
>
> According to Google, this is a COM problem. TXMLDocument uses COM to
> parse the xml file. So I need to first CoInitialize COM for the current
> thread, then later CoUnInitialize it. However, delphi help seems to not
> know of these two methods, and the only thing I can find is CoInitFlags,
> which is a variable in ComObjs (CoInitialize and CoUnInitialize don't
> seems to be in ComObjs), and for my application is set to 0
> (multithreaded). Not that I set it anywhere myself, but that is the
> value it has when I debug.
>
> A little about my application: It is a websnap app. I am introducing the
> xml bit to make it compatible with another application that shares some
> of the code base. The websnap application has always used ADO, which
> apparently has COM as well, and we've never had this problem. The xml is
> for setup, and is used in the creation of a particular web data module.
>
> Funnily enough, this problem is intermittant. When the first page called
> is the application's TWebAppPageModule everything is hunky dory for ever
> and ever. When the first page called is a TWebPageModule then it goes
> sour.
>
> It's not the best explanation, but hopefully someone can shed some light
> on this for me.
>
> _______________________________________________
> Delphi mailing list
> [EMAIL PROTECTED]
> http://ns3.123.co.nz/mailman/listinfo/delphi
>

_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to