您的位置:首页 > 编程语言 > Delphi

delphi xml 添加节点

2020-02-15 18:17 453 查看

<?xml   version= "1.0 "   encoding= "gb2312 "?> 
<File> 
    <aa> 
        <bb> bb </bb> 
    </aa> 
    <Handle> 客户端加密,服务器端解密 </Handle> 
    <FileId> 文件ID </FileId> 
    <FileName> 文件名 </FileName> 
    <FileSize> 文件大小 </FileSize> 
    <UploadDate> 上传日期 </UploadDate> 
    <UploadTime> 上传时间 </UploadTime> 
    <UploadMan> 上传人 </UploadMan> 
    <Note> 注释 </Note> 
</File> 
这是Delphi代码 
procedure   TForm1.Button1Click(Sender:   TObject); 
var   node:IXMLNode; 
begin 
    XMLDocument1.Active:=True; 
    node:=XMLDocument1.DocumentElement.ChildNodes.First.AddChild( 'tgp1c11 '); 
    node.Attributes[ 'class ']:= 'class '; 
    node.Attributes[ 'caption ']:= 'caption '; 
    node.Attributes[ 'left ']:= 'left '; 
    node.Attributes[ 'top ']:= 'top '; 
    node.Attributes[ 'width ']:= 'width '; 
    node.Text:= 'aaa '; 
    XMLDocument1.SaveToFile( 'c:\aa.xml '); 
end; 
下面是产生的XML文件 
<?xml   version= "1.0 "   encoding= "gb2312 "?> 
<File> 
<aa> 
<bb> bb </bb> 
<tgp1c11   class= "class "   caption= "caption "   left= "left "   top= "top "   width= "width "> aaa </tgp1c11> </aa> 
<Handle> 客户端加密,服务器端解密 </Handle> 
<FileId> 文件ID </FileId> 
<FileName> 文件名 </FileName> 
<FileSize> 文件大小 </FileSize> 
<UploadDate> 上传日期 </UploadDate> 
<UploadTime> 上传时间 </UploadTime> 
<UploadMan> 上传人 </UploadMan> 
<Note> 注释 </Note> 
</File> 

转载于:https://www.cnblogs.com/Mr-Xia/archive/2011/09/07/2169922.html

  • 点赞
  • 收藏
  • 分享
  • 文章举报
aaaq1231 发布了0 篇原创文章 · 获赞 0 · 访问量 315 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: