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; Procedure submit (Sender: Taobao); Procedure submit (Sender: tobject ); procedure button3click (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 '); {the same return value can be obtained only when an XML test file is provided.} end; // obtain the root element attribute procedure tform1.button1click (Sender: tobject); var nodelist: ixmlnodelist; node: ixmlnode; begin showmessage (inttostr (xmldocument1.documentelement. attributenodes. count); {1} showmessage (xmldocument1.documentelement. attributes ['note']); {test} {access the attribute by attribute name. Generally, attributes ['attribute name']} showmessage (xmldocument1.documentelement. attributenodes [0]. text); {test} {access attributes through attribute locations. attributenodes [location id]} {can also be accessed through attributenodes ['attribute name'], for example :} showmessage (xmldocument1.documentelement. attributenodes ['note']. text); {test} {attributenodes is the attribute list of a node. It is also a node list object, such as:} nodelist: = xmldocument1.documentelement. attributenodes; node: = nodelist [0]; showmessage (node. text); {test} node: = nodelist ['note']; showmessage (node. text); {test} end; // access the attributes of the second person procedure tform1.button2click (Sender: tobject); var nodelist: ixmlnodelist; node: ixmlnode; begin nodelist: = xmldocument1.documentelement. childnodes; node: = nodelist [1]; showmessage (inttostr (node. attributenodes. count); {1} showmessage (node. attributes ['post']); {Deputy Chief} showmessage (node. attributenodes [0]. text); {Deputy Chief} end; // access all attributes of a node procedure tform1.button3click (Sender: tobject); var nodelist: ixmlnodelist; node: ixmlnode; num, I: integer; begin nodelist: = xmldocument1.documentelement. childnodes; node: = nodelist [0]; num: = node. attributenodes. count; for I: = 0 to num-1 do begin showmessage (node. attributenodes [I]. text); {It will display: Section Chief at the current stage} end; end.