Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, xmldom, xmlintf, msxmldom, xmldoc, stdctrls; Type tform1 = Class (tform) button1: tbutton; xmldocument1: txmldocument; Procedure formcreate (Sender: tobject); Procedure button1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} 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; Procedure tform1.button1click (Sender: tobject); var node: ixmlnode; begin node: = xmldocument1.documentelement; node: = node. childnodes [0]; {the current node points to the first worker node} // attribute value: nodevalue is a readable showmessage (node. attributenodes [0]. nodevalue); {Section Chief} node. attributenodes [0]. nodevalue: = 'forward length '; showmessage (node. attributenodes [0]. nodevalue); {positive length} // attribute name: nodename is a read-only showmessage (node. attributenodes [0]. nodename); {position} // node. attributenodes [0]. nodename: = 'xxx'; {An error occurred when attempting to assign a value to the attribute name} node: = node. childnodes [0]; {the current node points to the Name node of the first employee "Zhang San"} // node value: nodevalue is a readable showmessage (node. nodevalue); {zhangsan} node. nodevalue: = 'zhang laosan '; showmessage (node. nodevalue); {Zhang laosan} // node name: nodename is a read-only showmessage (node. nodename); {name} // node. nodename: = 'xxx'; {An error occurred while trying to assign a value to the node name} end; end.