码迷,mamicode.com
首页 > 其他好文 > 详细

xmldocument的使用

时间:2014-07-23 21:11:06      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:delphixe6 xmldocument

TXMLDocument domvendor = ADOM XML v4

var
  root: IXMLnode;
  lei: IXMLNode;
  info: IXMLNode;
  i: integer;
  strxml:string;
  xmldoc:TXMLDocument;
begin
  cbbCountry.Items.Clear;
  try
    strxml := ‘<?xml version="1.0" encoding="GB2312"?>‘;
    strxml := strxml + (httprio1 as DataCenterServicesSoap).GetCZD(xz);
    xmldoc :=  TXMLDocument.create(nil);
    xmldoc.LoadFromXML(strxml);
    root := xmldoc.DocumentElement;
    lei := root.ChildNodes.First;
    while lei <> nil do
    begin
      if lei.NodeName = ‘Item‘ then
      begin
        info := lei.ChildNodes.First;
        clientdatasetcountry.append;
        while info <> nil do
        begin
          if info.NodeName = ‘unitId‘ then
          begin
            clientdatasetcountry.fieldbyname(‘unitId‘).value := info.text;
          end
          else if info.NodeName = ‘name‘ then
          begin
            clientdatasetcountry.fieldbyname(‘name‘).value := info.text;
          end;
          info := info.NextSibling;
        end;
      end;
      clientdatasetcountry.post;
      lei := lei.NextSibling;
    end;
 finally
   xmldoc.free;
 end;
  cbbcountry.items.Clear;
  clientdatasetcountry.first;
  while not clientdatasetcountry.eof do
  begin
    if  trim(clientdatasetcountry.FieldByName(‘name‘).asstring) <> ‘‘ then
      cbbcountry.items.add( clientdatasetcountry.FieldByName(‘name‘).asstring);
    clientdatasetcountry.next;
  end;

本文出自 “一切有为法,如梦幻泡影” 博客,请务必保留此出处http://kaixinbuliao.blog.51cto.com/2567365/1528423

xmldocument的使用

标签:delphixe6 xmldocument

原文地址:http://kaixinbuliao.blog.51cto.com/2567365/1528423

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!