Solved

TXMLDocument works on TForm, but not on TWebModule

Posted on 2012-04-09
12
562 Views
Last Modified: 2013-01-20
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.
0
Comment
Question by:AlfredMelbourne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 26

Expert Comment

by:EddieShipman
ID: 37825902
Try putting it in a DataModule and using the DM in your TWebModule.
0
 

Author Comment

by:AlfredMelbourne
ID: 37825919
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
0
 

Author Comment

by:AlfredMelbourne
ID: 37826226
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.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 26

Expert Comment

by:EddieShipman
ID: 37828303
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.
0
 

Author Comment

by:AlfredMelbourne
ID: 37830432
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?
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 500 total points
ID: 37832490
You have to use the off the Project->Import Type Library... menu. Select the version of Microsoft XML that you have installed. There may be many, and if so, select 3.0. The typelib will be placed in the Imports directory.
0
 

Assisted Solution

by:AlfredMelbourne
AlfredMelbourne earned 0 total points
ID: 37854221
I used AutomatedQA to find out what was going on. I finally got to the root of the problem as I got the message "CoInitialize has not been called". All I needed to do was the following:

uses
  ActiveX ....
...

  CoInitialize(nil);
  StringList1 := TStringList.Create;
  try
  XMLDocument1.LoadFromFile('C:\Temp\MyFile.xml');
  Response.Content := DisplayMessage('ok')
  except
    Response.Content := DisplayMessage('not ok')
    end;

Now I understand why the DLL's didn't work while the .EXE did.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 37855830
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.
0
 

Assisted Solution

by:AlfredMelbourne
AlfredMelbourne earned 0 total points
ID: 37858366
I ended up using Turbopower's XMLPartner. I had forgotten that I had bought it a decade ago. It is much easier than WP (which is not free).

I installed a newer - free - copy downloaded from http://sourceforge.net/projects/tpxmlpartner

I even had a written manual somewhere - the PDF version comes with the free install. I strongly recommend it.

Thanks for trying to help
0
 
LVL 1

Expert Comment

by:vviioo
ID: 37925722
Try calling CoInitialize before using the XMLDoc and COUninitialize when you are finished.
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 38798049
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month4 days, 22 hours left to enroll

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question