Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, xmldom, xmlintf, msxmldom, xmldoc, stdctrls; Type tform1 = Class (tform) xmldocument1: txmldocument; button1: tbutton; button2: tbutton; button3: tbutton; button4: tbutton; Procedure upload (Sender: tobject); Procedure button1click (Sender: tobject ); procedure button2click (Sender: tobject); Procedure button3click (Sender: tobject); Procedure button4click (Sender: tobject); Private {private Declarations} public {public declarations} end; var form1: tform1; implementation {$ R *. DFM} // open procedure tform1.formcreate (Sender: tobject); begin xmldocument1.loadfromfile ('C: \ temp \ test. XML '); {you must use the XML test file provided in case to have the same return value} end; // access the information of the first person procedure tform1.button1click (Sender: tobject ); begin showmessage (xmldocument1.documentelement. childnodes [0]. childnodes ['name']. text); {Zhang San} showmessage (xmldocument1.documentelement. childnodes [0]. childnodes ['gender']. text); {male} showmessage (xmldocument1.documentelement. childnodes [0]. childnodes ['age']. text); {34} {sub-nodes can be accessed by location. For example, childnodes [0] indicates the first element in the sub-node list} {sub-nodes can be accessed by the sub-node name, for example: childnodes ['name']} {but in the case of the same node name, you can only access through location} {in any case, you can access through location, for example :} showmessage (xmldocument1.documentelement. childnodes [0]. childnodes [0]. text); {Zhang San} end; // access the information of the second person procedure tform1.button2click (Sender: tobject); var nodelist: ixmlnodelist; node: ixmlnode; begin nodelist: = xmldocument1.documentelement. childnodes; node: = nodelist [1]; showmessage (node. childnodes ['name']. text); {Li Si} showmessage (node. childnodes ['gender']. text); {female} showmessage (node. childnodes ['age']. text); {43} end; // obtain all Member names procedure tform1.button3click (Sender: tobject); var nodelist: ixmlnodelist; node: ixmlnode; num, I: integer; begin nodelist: = xmldocument1.documentelement. childnodes; num: = nodelist. count; for I: = 0 to num-1 do begin node: = nodelist [I]; showmessage (node. childnodes ['name']. text); {It will show: Zhang San Li Si Wang Wu Sun 6} end; // get all member ages procedure tform1.button4click (Sender: tobject); var nodelist: ixmlnodelist; node: ixmlnode; num, I: integer; begin nodelist: = xmldocument1.documentelement. childnodes; num: = nodelist. count; for I: = 0 to num-1 do begin node: = nodelist [I]; showmessage (node. childvalues ['age']); {displayed: 34 43 25 52} end; end.