[Delphi 6] XML - Plantage lors de l'appel à "ChildNodes.FindNode"
Hello,
J'ai un crash sévère de mon appli au moment où je fais un "XMLDoc.DocumentElement.ChildNodes.FindNode('Nom');", et je ne comprends pas du tout d'où celà peut venir ?
Ci-joint le code (simplifié pour le source principal)
fichier test.xml
<Root>
<Nom>DUPONT</Nom>
<Prenom>Robert</Prenom>
</Root>
Appli principale :
Code:
1 2 3 4 5 6 7 8 9 10 11
|
.
.
uses xmlfunction;
.
.
.
procedure TForm1.Button1Click(Sender: TObject);
begin
P_read_XML_file ('C:\_dev\xml\test.xml');
end; |
Unité :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| unit xmlfunction;
interface
uses xmldom, XMLIntf, msxmldom, XMLDoc,Dialogs, SysUtils;
function P_read_XML_file (filename : string) : string;
implementation
function P_read_XML_file (filename : string) : string;
var XMLDoc: TXMLDocument;
Node : IXMLNode;
begin
try
XMLDoc := TXMLDocument.Create(nil);
XMLDoc.DOMVendor := DOMVendors.Find ('MSXML') ;
XMLDoc.Options := [doNodeAutoIndent, doAttrNull];
XMLDoc.Active := true;
If FileExists(filename) then
begin
XMLdoc.LoadFromFile(filename);
ShowMessage('Jusqu''ici tout va bien');
Node := XMLDoc.DocumentElement.ChildNodes.FindNode('Nom'); // PLANTAGE !
end;
finally
XMLDoc.Free;
end;
Result := 'Fin_procedure';
end;
end. |