Hi everybody,
I'm new to programming with freepascal/lazarus. I want to read nodes from an XML-File, but i get an Errormessage each time. Here is an excerpt of the xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Row>
<Group>Smartkamera Leuze</Group>
<Device>konfiguriert</Device>
<IP>10.62.121.120</IP>
<IPLAN>10.62.121.138</IPLAN>
</Row>
<Row>
<Group>Smartkamera Leuze</Group>
<Device>unkonfiguriert</Device>
<IP>192.168.60.101</IP>
<IPLAN>192.168.60.138</IPLAN>
</Row>
<Row>
<Group>Kamera Kognex</Group>
<Device>default</Device>
<IP>default</IP>
<IPLAN>192.168.1.1</IPLAN>
</Row>
<Row>
<Group>Regler</Group>
<Device>Lenze</Device>
<IP>default</IP>
<IPLAN>172.18.100.88</IPLAN>
And here is the excerpt of my code which i use to read the file:
procedure TForm1.btTestClick(Sender: TObject);
begin
datei := 'device.xml';
knoten := 'Group';
ReadXML(datei, knoten);
end;
procedure TForm1.ReadXML(var datei, knoten: string);
var
Doc: TXMLDocument;
PassNode: TDOMNode;
NodeText: String;
begin
cbDevice.Items.Append(PATH+datei);
cbDevice.Items.Append(knoten);
try
{ Read in xml file from disk }
ReadXMLFile(Doc, PATH+datei);
PassNode :=Doc.DocumentElement.FindNode(knoten);
try
NodeText :=PassNode.FirstChild.NodeValue;
finally
PassNode.Free;
end;
cbDevice.Items.Append(NodeText);
finally
Doc.Free;
end;
end;
Now when I start the program i get an error (attached) each time i press the "Test"-button.
Can anybody give me an hint what I'm doing wrong?