var
pRoot,cRoot,cRoot1,cRoot2 :IXMLNode;//pRoot根节点,cRoot子节点
i :Integer;
XMLDocument1: TXMLDocument;
begin
try
XMLDocument1.Active :=True ;
XMLDocument1.Version := '1.0'; //设置版本
XMLDocument1.ChildNodes.Clear;
XMLDocument1.Encoding := 'UTF-8';//'GB2312'; //设置语言
pRoot := XMLDocument1.AddChild('xml'); //添加的第一个节点是根节点, 现在的 mRoot 是根节点
cRoot := pRoot.AddChild('sys');//为根节点添加子节点}
cRoot.Text :='';
cRoot := pRoot.AddChild('items'); //为根节点添加子节点}
for i :=1 to 2 do
begin
cRoot1 := cRoot.AddChild('item'); //为根节点添加子节点}
cRoot1 := cRoot1.AddChild('head'); //为根节点添加子节点}
cRoot2 := cRoot1.AddChild('SiteCode');
cRoot2.Text := 'JSRM';
cRoot2 := cRoot1.AddChild('orgCode');
cRoot2.Text := 'JSRM';
cRoot2 := cRoot1.AddChild('ProcuctID');
cRoot2.Text := 'test00'+IntToStr(i);
cRoot2 := cRoot1.AddChild('MedicineName');
cRoot2.Text := 'testmedicinename';
cRoot2 := cRoot1.AddChild('ProductName');
cRoot2.Text := 'test product name';
cRoot2 := cRoot1.AddChild('ProductSpec');
cRoot2.Text := 'test product spec';
cRoot2 := cRoot1.AddChild('ProductStyle');
cRoot2.Text := 'test productstyl';
cRoot2 := cRoot1.AddChild('Manufacturer');
cRoot2.Text := 'test manufacturer';
cRoot2 := cRoot1.AddChild('CertificateNo');
cRoot2.Text := 'test certificateno';
cRoot2 := cRoot1.AddChild('ProductValue');
cRoot2.Text := 'test productvalue';
cRoot2 := cRoot1.AddChild('IsActive');
cRoot2.Text := 'Y';
cRoot2 := cRoot1.AddChild('IsQAStop');
cRoot2.Text := 'N';
cRoot2 := cRoot1.AddChild('IsStop');
cRoot2.Text := 'N';
cRoot2 := cRoot1.AddChild('UOM');
cRoot2.Text := '盒';
cRoot2 := cRoot1.AddChild('PriceList');
cRoot2.Text := '200';
cRoot2 := cRoot1.AddChild('UPC');
cRoot2.Text := '12345';
cRoot2 := cRoot1.AddChild('LPackageQty');
cRoot2.Text := '100';
cRoot2 := cRoot1.AddChild('Re');
cRoot2.Text := '无';
cRoot2 := cRoot1.AddChild('Timestamp');
cRoot2.Text := FormatDateTime('YYYY-MM-DD HH:MM:SS',Now);
end;
mmo2.Lines :=XMLDocument1.XML;
XMLDocument1.SaveToFile('99.xml');
XMLDocument1.Active :=False ; finally
end;end;//还有如果解析编码如何处理XMLDELPHI乱码webservices
pRoot,cRoot,cRoot1,cRoot2 :IXMLNode;//pRoot根节点,cRoot子节点
i :Integer;
XMLDocument1: TXMLDocument;
begin
try
XMLDocument1.Active :=True ;
XMLDocument1.Version := '1.0'; //设置版本
XMLDocument1.ChildNodes.Clear;
XMLDocument1.Encoding := 'UTF-8';//'GB2312'; //设置语言
pRoot := XMLDocument1.AddChild('xml'); //添加的第一个节点是根节点, 现在的 mRoot 是根节点
cRoot := pRoot.AddChild('sys');//为根节点添加子节点}
cRoot.Text :='';
cRoot := pRoot.AddChild('items'); //为根节点添加子节点}
for i :=1 to 2 do
begin
cRoot1 := cRoot.AddChild('item'); //为根节点添加子节点}
cRoot1 := cRoot1.AddChild('head'); //为根节点添加子节点}
cRoot2 := cRoot1.AddChild('SiteCode');
cRoot2.Text := 'JSRM';
cRoot2 := cRoot1.AddChild('orgCode');
cRoot2.Text := 'JSRM';
cRoot2 := cRoot1.AddChild('ProcuctID');
cRoot2.Text := 'test00'+IntToStr(i);
cRoot2 := cRoot1.AddChild('MedicineName');
cRoot2.Text := 'testmedicinename';
cRoot2 := cRoot1.AddChild('ProductName');
cRoot2.Text := 'test product name';
cRoot2 := cRoot1.AddChild('ProductSpec');
cRoot2.Text := 'test product spec';
cRoot2 := cRoot1.AddChild('ProductStyle');
cRoot2.Text := 'test productstyl';
cRoot2 := cRoot1.AddChild('Manufacturer');
cRoot2.Text := 'test manufacturer';
cRoot2 := cRoot1.AddChild('CertificateNo');
cRoot2.Text := 'test certificateno';
cRoot2 := cRoot1.AddChild('ProductValue');
cRoot2.Text := 'test productvalue';
cRoot2 := cRoot1.AddChild('IsActive');
cRoot2.Text := 'Y';
cRoot2 := cRoot1.AddChild('IsQAStop');
cRoot2.Text := 'N';
cRoot2 := cRoot1.AddChild('IsStop');
cRoot2.Text := 'N';
cRoot2 := cRoot1.AddChild('UOM');
cRoot2.Text := '盒';
cRoot2 := cRoot1.AddChild('PriceList');
cRoot2.Text := '200';
cRoot2 := cRoot1.AddChild('UPC');
cRoot2.Text := '12345';
cRoot2 := cRoot1.AddChild('LPackageQty');
cRoot2.Text := '100';
cRoot2 := cRoot1.AddChild('Re');
cRoot2.Text := '无';
cRoot2 := cRoot1.AddChild('Timestamp');
cRoot2.Text := FormatDateTime('YYYY-MM-DD HH:MM:SS',Now);
end;
mmo2.Lines :=XMLDocument1.XML;
XMLDocument1.SaveToFile('99.xml');
XMLDocument1.Active :=False ; finally
end;end;//还有如果解析编码如何处理XMLDELPHI乱码webservices
解决方案 »
- 现在DELPHI主流连接数据库方式是BDE还是ADO还是。。。
- deiphi 如何给这个页面提交数据呀??
- excel中的特殊字符在ACCESS中不识别的问题
- ◆AQuery更新数据后如何提交(COMMIT)?◆
- 谁有 delphi与数据库 相关的论文呀, 可不可以借我一看呀,偶正为这事儿烦着昵?
- delphi 新手,语法检查出错,帮忙看看
- delphi的控制输入法顺序是不是用注册表的?
- 为什么dlephi不能保存
- TDBGrid中,怎样得到某单元格的左上角相对于窗体的坐标以及这单元格的高度?
- (真正的高手请进)我知道一台远程服务器上的一个关于文件的url串,我怎才能操作这个文件呢?
- TMEMO中不断的memo.text := memo.text + string 内存会溢出
- delphi datasnap 服务端如何主动发信息给客户端
转换一下可不可以!