=====================================
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
XMLDocument1: TXMLDocument;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
myxm = class
bigclass: string;
smallclass: string;
sbwh: string;
end;
myhtmx:=class
mxhtno:string;
htpronam:string;
end;
myht:=class
htno:string;
htclass:string;
htbz:string;
mx:myhtmx;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
root: IXMLnode;
lei: IXMLNode;
info: IXMLNode;
mxinfo:IMLNode;
book: mybook;
i: integer;
begin
xmldocument1.LoadFromFile('xml.xml');
root := xmldocument1.DocumentElement;
lei := root.ChildNodes.First;
while lei <> nil do
begin
if lei.NodeName = 'XM' then
begin
xm_t := myxm.Create;
info := lei.ChildNodes.First;
while info <> nil do
begin
if info.NodeName = 'bigclass' then
xm_t.bigclass := info.Text
else if info.NodeName = 'smallclass' then
xm_t.bigclass := info.Text
else if info.NodeName = 'sbwh' then
xm_t.sbwh := info.Text;
info := info.NextSibling;
//showmessage('==xm==');
end;
memo1.Lines.Add(xm_t.bigclass + xm_t.smallclass + xm_t.sbwh);
end;
if lei.NodeName = 'HT' then
begin
ht_t := myht.Create;
info := lei.ChildNodes.First;
while info <> nil do
begin
if info.NodeName = 'htno' then
ht_t.htno := info.Text
else if info.NodeName = 'htclass' then
ht_t.htclass := info.Text
else if info.NodeName = 'htbz' then
ht_t.htbz := info.Text
else if info.NodeName='htmx' then
begin
mxinfo:=info.ChildNodes.first;
while mxinfo<>nil do
begin
if mxinfo.NodeName='MXHTNo' then
ht_t.mx.mxhtno:=mxinfo.text
else if mxinfo.NodeName='HTProNam' then
ht_t.mx.htpronam:=mxinfo.text
end;
end;
info := info.NextSibling;
//showmessage('==ht==');
end;
memo1.Lines.Add(ht_t.htno + ht_t.htclass + ht_t.htbz+ht_t.mx.mxhtno+ht_t.mx.htpronam);
end;
lei := lei.NextSibling;
end;