读如要填数据的XML文件:
procedure TfrmMain.readInfo;
var
// xmlDom1: TXMLDocument;
Nroot,Nentry,NsubEntry:IXMLNode;
filePath : string;
i:integer;
begin
filePath := ExtractFilePath(Application.ExeName) + 'infor.xml';
try
xmlDom1.LoadFromFile(filePath);
except
on e:exception do
showmessage(e.Message);
end;
Nroot:=xmldom1.DocumentElement;
Nentry:= Nroot.ChildNodes['level'];
level := Nentry.NodeValue;
Nentry:= Nroot.ChildNodes['ID'];
id := Nentry.NodeValue;
Nentry:= Nroot.ChildNodes['pwd'];
pwd := Nentry.NodeValue;
Nentry:= Nroot.ChildNodes['sex'];
sex := Nentry.NodeValue;
Nentry:= Nroot.ChildNodes['sr'];
sr := Nentry.NodeValue;
Nentry:= Nroot.ChildNodes['cFirstName'];
cFirstName := Nentry.NodeValue;
Nentry:= Nroot.ChildNodes['cLastName'];
cLastName := Nentry.NodeValue;
Nentry:= Nroot.ChildNodes['eFirstName'];
eFirstName := Nentry.NodeValue;
Nentry:= Nroot.ChildNodes['eLastName'];
eLastName := Nentry.NodeValue;
Nentry:= Nroot.ChildNodes['question'];
question := Nentry.NodeValue;
Nentry:= Nroot.ChildNodes['answer'];
answer := Nentry.NodeValue;
Nentry:= Nroot.ChildNodes['places'];
placeNum := Nentry.ChildNodes.Count;
for i := 1 to placeNum do
begin
places[i] := Nentry.ChildNodes[i-1].NodeValue;
placesID[i] := strtoint(Nentry.ChildNodes[i-1].NodeValue);
end;
end; |