unit Unit1;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Xml.XMLDoc, Xml.xmldom, Xml.XMLIntf,
Vcl.StdCtrls; type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);
var
IDoc: IXMLDocument;
Root, N1, N2, N3: IXMLNode;
I: Integer;
begin
IDoc := TXMLDocument.Create(nil);
IDoc.Active := True;
Root := IDoc.AddChild('公司');
for I := to do
begin
N1 := Root.AddChild('部门');
N1.Attributes['Id'] := I;
N1.AddChild('名称').NodeValue := '部门_'+I.ToString;
N1.AddChild('主管').NodeValue := '主管_'+I.ToString;
end;
IDoc.SaveToFile('d:\jjw.xml');
end; procedure TForm1.Button2Click(Sender: TObject);
var
Doc: IXMLDocument;
Node: IXMLNode;
I: Integer;
begin
Doc := TXMLDocument.Create(nil);
Doc.LoadFromFile('d:\jjw.xml');
Doc.Active := True;
Node := Doc.DocumentElement;
for I := to Node.ChildNodes.Count- do
Node.ChildNodes[I].AddChild('人数').NodeValue := IntToStr(I+);
Doc.SaveToFile('d:\jjw.xml');
end; procedure TForm1.Button3Click(Sender: TObject);
var
Doc: IXMLDocument;
Node: IXMLNode;
I: Integer;
begin
Doc := TXMLDocument.Create(nil);
Doc.LoadFromFile('d:\jjw.xml');
Doc.Active := True;
Node := Doc.DocumentElement;
for I := to Node.ChildNodes.Count- do
Node.ChildNodes[I].ChildNodes.Delete();
Doc.SaveToFile('d:\jjw.xml');
end; procedure TForm1.Button4Click(Sender: TObject);
var
Doc: IXMLDocument;
Root, Node: IXMLNode;
I: Integer;
begin
Doc := TXMLDocument.Create(nil);
Doc.LoadFromFile('d:\jjw.xml');
Doc.Active := True;
Root := Doc.DocumentElement;
for I := to Root.ChildNodes.Count- do
begin
Node := Root.ChildNodes[I];
if Node.Attributes['Id']= then
Node.ChildNodes[].NodeValue := ;
end;
Doc.SaveToFile('d:\jjw.xml');
end; end.

最新文章

  1. Android高手速成--第三部分 优秀项目
  2. Servlet基础(一) Servlet简介 关键API介绍及结合源码讲解
  3. cocos2dx 3.7中 AppDelegate.h的class TestController;这种写法的具体意思不太明白,只能猜是类似于外部定义的东西。
  4. 案例分析——BAT业务https化经历
  5. 【集训第三天·疯狂训练】哦,顺带学习了manacher
  6. app控件唯一相对Xpath自动生成(增强版uiautomatorviewer)
  7. 我的第一个python web开发框架(39)——后台接口权限访问控制处理
  8. STM32进入HardFault_Handler处理办法
  9. fabric读书笔记
  10. Windows Phone本地数据库(SQLCE):4、[Column]attribute(翻译) (转)
  11. matplot 代码实例2
  12. 移动前端兼容性笔记 - 安卓2.x 自带原生浏览器箭头问题
  13. /etc/default/useradd配置文件详解
  14. ExtJS ComboBox同时加载远程和本地数据
  15. Docker安装及常用操作
  16. hint指定index的深入理解
  17. IDHTTP用法详解 good
  18. Java 实现桥接(Bridge)模式
  19. js判断object的具体类型(或者说判断object的类class)
  20. User-defined types

热门文章

  1. Promise使用
  2. MDK编译过程
  3. hdoj5769后缀自动机版本
  4. Tinkoff Internship Warmup Round 2018 and Codeforces Round #475 (Div. 1)D. Frequency of String
  5. leetcode-956. 最高的广告牌
  6. 关于wincc与博图的安装问题
  7. laravel5.5 调用系统自带登陆认证auth
  8. SQL DELETE 语句详解
  9. mysql InnoDB index 主键采用聚簇索引,二级索引不采用聚簇索引
  10. 查看shell 命令 路径