惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
D
Docker
Vercel News
Vercel News
IT之家
IT之家
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
腾讯CDC
Google DeepMind News
Google DeepMind News
I
InfoQ
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
博客园 - Franky
The Cloudflare Blog
A
About on SuperTechFans
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
T
Tenable Blog
P
Proofpoint News Feed
Recorded Future
Recorded Future
Security Latest
Security Latest
H
Hackread – Cybersecurity News, Data Breaches, AI and More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
The Hacker News
The Hacker News
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
F
Full Disclosure
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
Project Zero
Project Zero

博客园 - azhai

sqlserver 实现数据变动触发信息 优化网站 推荐一款UI设计软件Balsamiq Mockups ubuntu 添加公钥 ubuntu 10.10 安装 redmine 收藏常用正则表达式 - azhai - 博客园 ubuntu 10.10 安装步骤 - azhai ubuntu 搭建NAT、DHCP、VPN服务 - azhai ubuntu 10.10 网络连接消失问题解决办法 远程连接mysql超时的解决办法 ubuntu apache2 的负载均衡和反向代理 ubuntu 下的两个项目管理工具 jquery 图片轮询 netbeans 字体美化 windows7 安装 virtualbox和 ubuntu SSL on Ubuntu 8.10 Apache2 博文阅读密码验证 - 博客园 用IDHTTP 实现上传和返回XML delphi 开发扩展(二)
线程加载返回的XMLtoTClientDataSet
azhai · 2009-11-03 · via 博客园 - azhai

type
  TReadOrderThread = class(TThread)
  private
    FCDS: TClientDataSet;
    Fstr: string;

  protected

    procedure Execute; override;
    procedure readOrder;

    function  XMLToDataSet(strXML:WideString;nodeName:string):TClientDataSet;

  public
    constructor Create(str:string);  overload;

  end;

function PostWebPage(url,para:String;TimeOut:Integer):WideString;
var
  tmpWeb:TIdHTTP;
  IdSSL : TIdSSLIOHandlerSocketOpenSSL;
  retrun:String;
  Proxy:String;
  i:Integer;
  paralist:TStrings;
  Response2: TStringStream;

begin
  retrun:='';
  try
    //Response2:= TStringStream.Create('');
    paralist:=TStringList.Create;
    paralist.Text:=StringReplace(para,'&',#13#10,[rfReplaceAll]);
    IdSSL:= TIdSSLIOHandlerSocketOpenSSL.Create(nil);
    IdSSL.SSLOptions.Method:=sslvSSLv3;
    tmpWeb:=TIdHTTP.Create(nil);

    tmpWeb.IOHandler:=IdSSL;

    tmpWeb.ReadTimeout:=TimeOut;
    tmpWeb.Request.ContentType:='application/x-www-form-urlencoded';
    try
    retrun:=tmpWeb.Post(url,paralist);
    except
     on e:exception do
      showmessage(e.Message);

    end;
    sleep(500);
   // retrun:=Utf8ToAnsi(paralist.Text);

  finally
      tmpWeb.Disconnect;
      FreeAndNil(tmpWeb);
      //Response2.Free;
      FreeAndNil(paralist);
  end;
  Result:=retrun;
end; 

 constructor TreadOrderThread.Create(str:string);
begin
  FreeOnTerminate := True;
  Fstr := str;
  FCDS:=TClientDataSet.Create(nil);
  inherited Create(False);
end;

function   TreadOrderThread.XMLToDataSet(strXML:WideString;nodeName:string):TClientDataSet;
  var
      myDataSet:TClientDataSet;
      s:string;
      xdoc   :   IXMLDOMDocument;
      xdn   :IXMLDOMNode;
      xdns   :IXMLDOMNodeList;
      i,j:integer;
      d,ii:integer;
      sumtotal,sumje,dj,je:double;
      sl:integer;
begin

  myDataSet   :=   TClientDataSet.Create(nil);
  xdoc:=CreateDOMDocument();
  xdoc.loadXML(strXML);
  sumtotal:=0;
  sumje:=0;
  s:='';
  xdn:=xdoc.documentElement;
  xdns:=xdoc.selectNodes('//'+nodeName);
  try
  begin
    try
      for i:=0 to xdns.item[0].childNodes.length-1 do
      begin
        myDataSet.FieldDefs.Add(xdns.item[0].childNodes[i].nodeName,ftstring,1000);
      end;
    except
       Application.MessageBox('没有查询到数据。','提示',32);
       exit;
    end;

    try
       myDataSet.CreateDataSet;                      //建立
       myDataSet.Active;

    except;
    end;

    d:=0;
    for i:=0 to xdns.length-1 do
    begin
       myDataSet.Append;
          myDataSet.FieldValues[xdns.item[i].childNodes[j].nodeName]:=xdns.item[i].childNodes[j].text;
       end;
     
       myDataSet.Post;
    end;

    end;
      except
      on   Ex:Exception   do
      begin
        myDataSet:=nil;
        FCDS.Active:=false;

      end;
   end;

      result:=myDataSet;
    
  end;

 procedure TreadOrderThread.Execute;
var
  OwnerData: OleVariant;

begin
  try
       FCDS.Active:=false;

    //while not self.Terminated do
    //begin
       self.Synchronize(readOrder);
       sleep(50);
     //  if (_total>(total/page)) or (total=0) then
      //   self.Terminate();
   // end;
  finally
   // CoUninitialize;
  end;
end;