How to create an XML file using tclientdataset-Reply to "ding Yongqi"

Source: Internet
Author: User
Problem Source: http://www.cnblogs.com/del/archive/2008/06/12/1114450.html#1223758
In this example:


Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, DB, dbclient; Type tform1 = Class (tform) clientdataset1: tclientdataset; button1: tbutton; button2: tbutton; button3: tbutton; button4: tbutton; memo1: tmemo; procedure invoke (Sender: tobject); Procedure button2click (Sender: tobject ); procedure button3click (Sender: tobject); Procedure button4click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses xmldoc; {to use the formatxmldata function} procedure tform1.button1click (Sender: tobject); begin clientdataset1.fielddefs. clear; with clientdataset1.fielddefs. addfielddef do begin name: = 'name'; datatype: = ftstring; Size: = 10; end; with clientdataset1.fielddefs. addfielddef do begin name: = 'age'; ype: = ftinteger; end; clientdataset1.createdataset; // temperature: = false; clientdataset1.open; end; Procedure tform1.button2click (Sender: tobject ); begin clientdataset1.append; clientdataset1.fields [0]. value: = 'zhang san'; clientdataset1.fields [1]. value: = 11; clientdataset1.append; clientdataset1.fields [0]. value: = 'lily'; clientdataset1.fields [1]. value: = 22; end; Procedure tform1.button3click (Sender: tobject); begin memo1.clear; memo1.text: = formatxmldata (clientdataset1.xmldata); end; procedure invoke (Sender: tobject ); begin clientdataset1.savetofile ('C: \ temp \ myxml. xml', dfxml); {use the following sentence if the format is beautiful:} memo1.lines. savetofile ('C: \ temp \ myxml2.xml '); end.
 
   
 

Form file:

Object form1: tform1 left = 0 Top = 0 caption = #20381 #27425 #28857 #20987 #25353 #38062 clientheight = 211 clientwidth = 445 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false position = podesktopcenter pixelsperinch = 96 textheight = 13 object button1: tbutton left = 358 Top = 21 width = 75 Height = 25 caption = #21019 #24314 taborder = 0 onclick = button1click end object button2: tbutton left = 358 Top = 64 width = 75 Height = 25 caption = #28155 #21152 taborder = 1 onclick = button2click end object button3: tbutton left = 358 Top = 108 width = 75 Height = 25 caption = #26597 #30475 taborder = 2 onclick = button3click end object button4: tbutton left = 358 Top = 152 width = 75 Height = 25 caption = #20445 #23384 taborder = 3 onclick = button4click end object memo1: tmemo left = 0 Top = 0 width = 345 Height = 211 align = alleft lines. strings = ('memo1') scrollbars = ssboth taborder = 4 end object clientdataset1: tclientdataset aggregates = Params = left = 168 Top = 8 endend
 
   
 

Open it and you will findProgramIt is not rigorous, but it can explain the problem and will not be modified.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.