zoukankan      html  css  js  c++  java
  • delphi读取xml文件

      功能:  根据省份更新地市信息
    -------------------------------------------------------------------------------}
    procedure TForm.GetCityInfo;
    var
      iXMLAreaFile : IXMLDocument;
      sFileName,aProvince,sProvince,sCity : string;
      nCol,nNum,nCityCount,nprovinceCount : Integer;
    begin
      iXMLAreaFile := TXMLDocument.create(nil);
      sFileName :=  getexepath + 'Province.xml';
      iXMLAreaFile.FileName := sFileName;
      iXMLAreaFile.active := True;
      sProvince := cbbprovince.Text;
      if sProvince = '全部' then
      begin
        cbbcity.Items.Clear;
        cbbcity.Items.Add('全部');
        cbbcity.ItemIndex := 0;
      end
      else
      begin
        cbbcity.Items.Clear;
        cbbcity.Items.Add('全部');
        cbbcity.ItemIndex := 0;
        nprovinceCount := iXMLAreaFile.DocumentElement.childnodes.Count;
        for nNum := 0 to nprovinceCount-1 do
         begin
           //获取province节点内容
           aProvince := iXMLAreaFile.DocumentElement.ChildNodes[nNum].
           AttributeNodes[0].nodevalue;
           if aProvince = sProvince then
           begin
             ncityCount := iXMLAreaFile.DocumentElement.childnodes[nNum].childnodes.Count;
             //获取市级节点内容
             for nCol := 0 to ncitycount-1 do
             begin
               sCity := iXMLAreaFile.DocumentElement.ChildNodes[nNum].
               childnodes[nCol].AttributeNodes[0].nodevalue;
               cbbCity.Items.Add(sCity);
             end;
           end;
         end;
      end;
    end;
    View Code
  • 相关阅读:
    请假两时间的小时数差
    Python3之旅
    python语法总结1
    关于命令行的小结
    从Java到C#再到python
    数据库知识
    Visual Studio高低版本的问题(以2008和2015为例)
    web api
    readoney和const
    null
  • 原文地址:https://www.cnblogs.com/key-ok/p/3429849.html
Copyright © 2011-2022 走看看