由数据库数据生成XML的方法(有源码)[5]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 oklemon 的 blog

         child1.appendchild(doc.createtextnode(temp)); 
        end; 
      table.next; 
      end; 
      doc.save(xml+'.xml'); 
      memo1.lines.append(doc.xml); 
      result:=1; 
    except 
      on e:exception do 
        result:=-1; 
    end; 
  end; 
  
  在button1的onclick事件中调用上面的函数
  procedure tform1.button1click(sender: tobject); 
  begin 
    if makexml(table1)=1 then 
      showmessage('xml generated') 
    else 
      showmessage('error while generating xml file'); 
  end; 
  
  如果你用ie 5.0(或以上版本)打开生成的country.xml文件,它看起来会成下面的样子
  - <country> 
              - <records> 
                        <name>argentina</name> 
                        <capital>buenos aires</capital> 
                        <continent>south america</continent> 
                        <area>2777815</area> 
                        <population>32300003</population> 
                </records> 
              - <records> 
                        <name>bolivia</name> 
                        <capital>la paz</capital> 
                        <continent>south america</continent> 
                        <area>1098575</area> 
                        <population>7300000</population> 
                </records> 
                        . 
                        . 
                        . 
              - <records> 
                        <name>venezuela</name> 
                        <capital>caracas</capital> 
                        <continent>south america</continent> 

本文关键:xml delphi
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top