Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, xmldom, xmlintf, msxmldom, xmldoc, stdctrls; Type tform1 = Class (tform) xmldocument1: txmldocument; memo1: tmemo; button1: tbutton; button2: tbutton; button3: tbutton; button4: tbutton; button5: tbutton; Procedure upload (Sender: tobject ); procedure button1click (Sender: tobject); Procedure Button2click (Sender: tobject); Procedure button3click (Sender: tobject); Procedure button4click (Sender: tobject); Procedure destroy (Sender: tobject); 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; // XML Attribute procedure tform1.button1click (Sender: Tobject); begin {we often use this sentence before, because the lines and XML here belong to tstrings} memo1.lines: = xmldocument1.xml; {if you are not afraid of trouble, you can also write it like this :} memo1.lines. text: = xmldocument1.xml. text; {if you know this, there will be more functions of the XML attribute, and the XML Attribute here is writable} {but here we will talk about the XML Attribute of the node} end; // The XML Attribute procedure tform1.button2click (Sender: tobject) of the root node; var node: ixmlnode; begin {first view the root node: xmldocument1.documentelement} node: = xmldocument1.documentelement; // memo1.lines: = Node. XML; {this sentence will cause an error} {because the XML Attribute of the node is of the widestring type, it should be like this:} memo1.lines. text: = node. XML; {all content contained in the root node and the root node will be read.} {There is another bigger difference: the XML of the node is read-only !} End; // The XML Attribute procedure tform1.button3click (Sender: tobject) of the subnode; var node: ixmlnode; begin node: = xmldocument1.documentelement; node: = node. childnodes [0]; memo1.lines. text: = node. XML; {displays all of the Child Nodes} end; // The XML Attribute procedure tform1.button4click (Sender: tobject); var node: ixmlnode; begin node: = xmldocument1.documentelement; node: = node. attributenodes [0]; {the property is also of the ixmlnode type} showmessage (node. nodename); {remarks} showmessage (node. nodevalue); {test} {read them all once using XML attributes:} showmessage (node. XML); {remarks = "test"} end; // The XML Attribute procedure tform1.button5click (Sender: tobject) of the leaf node; var node: ixmlnode; begin node: = xmldocument1.documentelement; node: = node. childnodes [0]; node: = node. childnodes [0]; node: = node. childnodes [0]; {This is the leaf node} showmessage (node. XML); {zhangsan} {the XML Attribute is the same as the text attribute} showmessage (node. text); {zhangsan} end; end.