uses ...... Laz2_DOM,laz2_XMLRead,laz2_XMLWrite,......
var Doc: TXMLDocument; // variable to document RootNode,LeftNode,RightNode,parentNode: TDOMNode; // variable to nodes i: integer; begin // Create a document Doc := TXMLDocument.Create; // Create a root node RootNode := Doc.CreateElement('ROOT'); Doc.Appendchild(RootNode); // save root node // RootNode:= Doc.DocumentElement; LeftNode := Doc.CreateElement('left'); RootNode.Appendchild(LeftNode); parentNode := Doc.CreateElement('element'); TDOMElement(parentNode).SetAttribute('name',PanelMainLeft.Controls[i].Name); // create atributes to parent node TDOMElement(parentNode).SetAttribute('left',intToStr(PanelMainLeft.Controls[i].Left)); TDOMElement(parentNode).SetAttribute('width',intToStr(PanelMainLeft.Controls[i].Width)); TDOMElement(parentNode).SetAttribute('top',intToStr(PanelMainLeft.Controls[i].Top)); TDOMElement(parentNode).SetAttribute('height',intToStr(PanelMainLeft.Controls[i].Width)); LeftNode.Appendchild(parentNode); writeXMLFile(Doc,'test.xml'); // write to XML Doc.Free; // free memory end;原文链接:https://www.f2er.com/xml/296207.html