The data window in powerbuilder is really good. it basically focuses on it and is very efficient. xml files need to be exported to projects in the past few days, we used pb9 (the xml export and import function was added from powerbuilder9.0) to make a demo to verify the feasibility of the data window in powerbuilder. Basically, the work is centered on it, very efficient. in the past few days, if the project needs to export xml files, pb9 (the xml export and import function is added from powerbuilder9.0) is used to make a demo to verify the feasibility.
The sample file is as follows (without adding a DTD, for example, to describe it)
The code is as follows:
My table structure, I think everyone's tables should be designed in this way.
Order (sales order, including customer, date, and other information)
Orderdetail (sales order details, including product, quantity, and price information)
At this point, we may be able to see at a glance that there are some problems with the xml format settings. for example, this may be more reasonable.
The code is as follows:
However, people are government departments, and they cannot be changed, so they have to do it in a bad way.
Processing code in pb9: in fact, only three lines of code are written in pb9. there is actually only one line of code, that is, a window is added with a data window and a button, this line of code is written in the button.
Dw_export.save ("c: \ test. xml", xml !, False)
In fact, what really needs to be processed is to define two data windows, mainly to define their xml templates:
D_order (export of order header data, second line of code, which can be set in EITX)
1. create a data window (note that if the conditional data contains multiple rows, it is best to group the data in SQL; otherwise, the generated data will be duplicated)
3. right-click the editing area in export/import template xml (EITX) and save as another name.
4. set the use template under data export to your saved template name.
The defined template is as follows:
The code is as follows:
Order_date
Dw_detail
Note the following two points:
[Note 1] This start detail will control the data loop, so you need to select it, but each xml can only define one. here there will be a problem. if after the order header loop, how can we repeat the order details loop? the conclusion is that it cannot be implemented in a data window and must be processed in a data window. Note 2
[Note 2] we need to insert a report in d_order, that is, d_orderdetail. in the control list in d_order (same as in datawindow control refrence), it is dw_detail (the default name is dw_1, I changed my name)
D_orderdetail (export of order details data, that is, the data window referenced by report and dw_detail above. The third line of code can be set in EITX)
1. new data window
2. right-click the editing area in export/import template xml (EITX) and save as another name.
3. set the use template under data export to your saved template name.
Product_name
[Note 3] Note that when we export xml in d_order, the xml declaration in d_orderdetail and the top node will be ignored.
[Note 4] orderdetail is defined here. because an order may have multiple details, we need to set it to start detail, that is, a loop.
The last generated file is as follows:
The code is as follows:
20080101
Jia
Already
20080102
Jia
C
Note: If you want to design an xml interface file, you must consider the convenience of users.
The above is the detailed content of the code sample used by xml in powerbuilder. For more information, see other related articles in the first PHP community!