procedure TfrmTallageDetail.ToolButton1Click(Sender: TObject);
var
Xml: TXMLDocument;
Rootbusiness,Rootgroup,Rootdata : IXMLNode;
business,group,data: IXMLNode;
begin
//加入版本信息 ‘<?xml version="1.0" encoding="GBK" ?> ’
Xml.Active := True;
Xml.Version := '1.0';
Xml.Encoding :='GBK';
Rootbusiness := Xml.CreateNode('business');
Xml.DocumentElement := Rootbusiness;
Rootbusiness.SetAttribute('id','FP56');
Rootbusiness.SetAttribute('comment','外部发票报送');
Rootgroup := Xml.CreateNode('group');
Rootbusiness.ChildNodes.Add(Rootgroup);
Rootdata := Xml.CreateNode('data');
Rootdata.SetAttribute('nsrsbh','纳税人识别号');
Rootdata.SetAttribute('wdbh','网点编号');
Rootgroup.ChildNodes.Add(Rootdata);
//单张发票信息
business := Xml.CreateNode('business');
business.SetAttribute('id','FPMX.DZFP');
business.SetAttribute('comment','单张发票信息');
Rootgroup.ChildNodes.Add(business);
Xml.SaveToFile('aaa.xml');
xml.Active := False;
showmessage('创建成功!');
finally
Xml.Free;
end;
上面是delphi自定义xml的简单例子。
|
请发表评论