Create a local data set
Clientdataset2. Fielddefs.clear;;
With Clientdataset2. Fielddefs.addfielddef do
Begin
Name: = ' id ';
Size: = 10;
DataType: = ftstring;
End
With Clientdataset2. Fielddefs.addfielddef do
Begin
Name: = ' XM ';
Size: = 10;
DataType: = ftstring;
End
With Clientdataset2. Fielddefs.addfielddef do
Begin
Name: = ' xb ';
Size: = 10;
DataType: = ftstring;
End
With Clientdataset2. Fielddefs.addfielddef do
Begin
Name: = ' nl ';
DataType: = Ftinteger;
End
With Clientdataset2. Fielddefs.addfielddef do
Begin
Name: = ' Sfzh ';
Size: = 10;
DataType: = ftstring;
End
With Clientdataset2. Fielddefs.addfielddef do
Begin
Name: = ' Jtzz ';
Size: = 30;
DataType: = ftstring;
End
Clientdataset2. CreateDataSet;
Clientdataset2.open;
Import XML
Var
Xml:tnativexml;
Root:tsdelement;
I:integer;
Statement SoapHeader
Aintf:datacenterservicessoap;
Headers:isoapheaders;
H:securitysoapheader2;//securitysoapheader2;
Begin
Try
Clientdataset2. Emptydataset;
XML: = Tnativexml.create (nil);
Send SoapHeader
aintf: = (httprio1 as Datacenterservicessoap);
H: = securitysoapheader2.create;
H.ticket: = ' be2e4f35-cde9-46a1-844b-9fb2546491b2 ';
Headers: = (aintf as isoapheaders);
Headers.send (H); Send Soap Header
Xml. Readfromstring (Httprio1 as Datacenterservicessoap). Getdataasxml (Memo1. Text));
Aintf.getinfo; Invoke Service
Xml. Readfromstring (Httprio1 as Datacenterservicessoap). GetXML (Memo1. Text));
Xml. Xmlformat: = xfreadable;
Root: = XML. Root;
For I: = 0 to root. NodeCount-1 do
Begin
Clientdataset2. Append;
Clientdataset2. Fieldbyname (' id '). Value: = Root[i]. Nodebyname (' ID '). Value;
Clientdataset2. Fieldbyname (' XM '). Value: = Root[i]. Nodebyname (' XM '). Value;
Clientdataset2. Fieldbyname (' XB '). Value: = Root[i]. Nodebyname (' XB '). Value;
Clientdataset2. Fieldbyname (' nl '). Value: = Root[i]. Nodebyname (' nl '). Value;
Clientdataset2. Fieldbyname (' Sfzh '). Value: = Root[i]. Nodebyname (' Sfzh '). Value;
Clientdataset2. Fieldbyname (' Jtzz '). Value: = Root[i]. Nodebyname (' Jtzz '). Value;
Clientdataset2. Post;
End
Finally
aintf: = nil;
End;
Xml. Free;
H.free;
This article is from the "All for the law, such as Fleeting Dream" blog, please be sure to keep this source http://kaixinbuliao.blog.51cto.com/2567365/1440573
Accessing webservice, importing XML to a local data set