Error load XML

Please discuss general Delphi programming topics here.

Error load XML

Postby araldi » October 14th, 2009, 10:23 am

Hello,

Firstly I would like to say sorry for my low level english.

Well, my problem is I am trying to do a program wich read from a xml file. I am programing in delphi 6.

This is a part of code where you can see the commands that I use.

procedure TForm1.Button1Click(Sender: TObject);
var
XMLInfoService: TXMLDocument;
IXMLNodeError: IXMLNode;
begin

try
XMLInfoService := TXMLDocument.Create(nil);
XMLInfoService.LoadFromFile ('Prueba.xml');
XMLInfoService.Active := True;

IXMLNodeError := XMLInfoService.DocumentElement.ChildNodes.FindNode('error').ChildNodes.FindNode('cod_error');

If I stop the process in XMLInfoService.Active := True, when I put the cursor over XMLInfoService.LoadFromFile('Prueba.xml'), appears a tag that contain this:

XMLInfoService.LoadFromFile = Inaccesible value

And when the process arrives to IXMLNodeError := ..., the program stops with EAccessViolation error.

Could someone help me?

Thanks.
araldi
Member
Member
 
Posts: 2
Joined: October 14th, 2009, 10:20 am

Re: Error load XML

Postby Kambiz » October 14th, 2009, 3:47 pm

Here is a solution:

Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
  XMLInfoService: IXMLDocument;
  IXMLNodeError: IXMLNode;
begin
  XMLInfoService := LoadXMLDocument('Prueba.xml');
  // XMLInfoService is already active, and you do not need to release it

end;
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 8 guests

cron