Link to home
Start Free TrialLog in
Avatar of AlfredMelbourne
AlfredMelbourne

asked on

TXMLDocument works on TForm, but not on TWebModule

I used a test program to make TXMLDocument work the way I wanted and to parse successfully a document.

When I tried to reproduce the same on a TWebModule, it compiled OK, but always failed when reference was made to the TXMLDocument. I tried it both as a component and as a class. I was using the same input file in both cases.

XMLDocument1 := TXMLDocument.Create(nil);

There are plenty of examples here and on the internet of similar usage. BTW, I am running Delphi 7 and Wndows XP. Is there something that I need to install, or suchlike.
Avatar of Eddie Shipman
Eddie Shipman
Flag of United States of America image

Try putting it in a DataModule and using the DM in your TWebModule.
Avatar of AlfredMelbourne
AlfredMelbourne

ASKER

Thank you Eddie. Perhaps I have not made myself clear. The failure occurs on the statement

XMLDocument1 := TXMLDocument.Create(nil);

when I am tracing it - before the data has even been read!

If I use a component, which has already been created, it fails when I do a LoadFrommStream or LoadFromFile
FWIW, I tried TALXMLDocument and had exactly the same problem. OTOH, when I tried TWPXMLTree, it worked fine. Obviously, I will have to use WPTools now.

However, I would love to get those other XML parsers to work on my website.
Personally, I never liked using the TXMLDocument wrapper and used the IXMLDOMDocument directly.
uses ... MSXML3_TLB;

var
  oXMLDomDocument : IXMLDOMDocument;
begin
  oXMLDomDocument := CreateOleObject('MSXML2.DOMDocument') as IXMLDOMDocument;
  // use the oXMLDomDocument using the OLE calls.
  oXMLDomDocument.load(XMLDocument_filename);
  .. etc...
end;

Open in new window


If you need more help parsing the document, please post it and tell how you want it parsed.
I think we are getting somewhere.

I don't seem to have MSXML_TLB.pas or MSXML3_TLB on my PC. Where do they come from?
ASKER CERTIFIED SOLUTION
Avatar of Eddie Shipman
Eddie Shipman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It would have been easier to just use the MSXML TypeLib but if you got it working, great.
That is one reason I do not like using TXMLDocument and another is because it is so convoluted. I began working with MXSML back in 1998, before the TXMLDocument wrapper was even written so I know that way much better.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try calling CoInitialize before using the XMLDoc and COUninitialize when you are finished.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.