Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Read from XML

6 views
Skip to first unread message

Serge

unread,
Aug 20, 2003, 7:33:27 AM8/20/03
to
Has someone an sample for me how to read from an xml file using TXMLDocument
?

thnx


Serge

unread,
Aug 20, 2003, 9:09:55 AM8/20/03
to
Warum crasht, das immer :) ?

function ReadXMLIni(_xmlfile : string) : boolean;
var
i : integer;
begin
try
xIniDoc.LoadFromFile(_xmlfile);
xIniDoc.Active := true;

xIniRoot := xIniDoc.DocumentElement; --> Access violation :(
xIniList := xIniRoot.ChildNodes;

for i := 0 to xIniList.Count-1 do
begin
writeln(xIniList.Nodes[i].NodeName+ ' = ' + xIniList.Nodes[i].text);
end;
except
on e: exception do jLog(0, e.Message);
end;
end;


Ben Damm

unread,
Aug 29, 2003, 4:05:24 PM8/29/03
to
I have this problem as well. My platform is Windows 2003 and Delphi
7. The following snippet crashes:

procedure TForm1.Button1Click(Sender: TObject);
Var
tDoc:TXMLDocument;
begin
tDoc := TXMLDocument.Create(nil);
tDoc.LoadFromXML('<a/>');

tDoc.DocumentElement; // <-- EAccessViolation
end;

Any light that could be shed on this would be much appreciated!

Thanks,
-Ben

Ben Damm

unread,
Sep 3, 2003, 3:55:42 PM9/3/03
to
Ok, I discovered the solution. The TXMLDocument declaration needs to
be an IXMLDocument declaration, like so:

Var
tDoc:IXMLDocument;
begin
tDoc := TXMLDocument.Create(....

bdamm-...@dammfine.com (Ben Damm) wrote in message news:<6448d1e6.03082...@posting.google.com>...

Ben Damm

unread,
Sep 3, 2003, 3:55:47 PM9/3/03
to
Ok, I discovered the solution. The TXMLDocument declaration needs to
be an IXMLDocument declaration, like so:

Var
tDoc:IXMLDocument;
begin
tDoc := TXMLDocument.Create(....

bdamm-...@dammfine.com (Ben Damm) wrote in message news:<6448d1e6.03082...@posting.google.com>...

0 new messages