Delphi向XML中添加节点数据.rar

时间:2022-07-30 06:22:45
【文件属性】:
文件名称:Delphi向XML中添加节点数据.rar
文件大小:7KB
文件格式:RAR
更新时间:2022-07-30 06:22:45
Delphi源码-文件操作 Delphi7向常用的XML文件中添加内容,按照XML的节点规则依次写入内容,自定义各个节点及节点内容,具体的操作代码如下示:   var    iXml: IDOMDocument;    iRoot, iNode, iNode2, iChild, iAttribute: IDOMNode;   begin    XMLDocument1.Active := False;    XMLDocument1.XML.Text := '';    XMLDocument1.Active := True;    iXml := XMLDocument1.DOMDocument;    iRoot := iXml.appendChild (iXml.createElement ('xml'));    iNode := iRoot.appendChild (iXml.createElement ('test'));    iNode.appendChild (iXml.createElement ('test2'));    iChild := iNode.appendChild (iXml.createElement ('test3'));    iChild.appendChild (iXml.createTextNode('simple value'));    iNode.insertBefore (iXml.createElement('test4'), iChild);    iNode2 := iNode.cloneNode (True);    iRoot.appendChild (iNode2);    iAttribute := iXml.createAttribute ('color');    iAttribute.nodeValue := 'red';    iNode2.attributes.setNamedItem (iAttribute);    Memo1.Lines.Text := FormatXMLData (XMLDocument1.XML.Text);   end;   你还可以点击源码下载按钮,下载本示例完整源码。
【文件预览】:
srcfans.com
----Delphi向XML中添加节点数据()
--------Unit1.ddp(51B)
--------Project1.res(876B)
--------Unit1.dcu(6KB)
--------Unit1.dfm(920B)
--------Project1.cfg(434B)
--------Project1.dpr(188B)
--------Project1.dof(3KB)
--------Unit1.pas(2KB)

网友评论