My goal is to generate xml structure in this format
<?xml version='1.0' encoding='UTF-8'?>
<return xmlns:rmas="value here" xmlns:xsi="value here" xsi:noNamespaceSchemaLocation="value here">
<header>
<return-code>""</return-code>
<return-desc>""</return-desc>
<as-at-date>""</as-at-date>
<operator-code>""</operator-code>
</header>
<body>
<scheme>
<code>10050</code>
<employer>
<empr-code></empr-code>
<data>
<serial-no />
<pin />
<employer-contribution />
<employee-contribution />
<voluntary-contribution />
<total-contribution />
</data>
</employer>
</scheme>
<scheme>
<code>10100</code>
<employer>
<empr-code></empr-code>
<data>
<serial-no />
<pin />
<employer-contribution />
<employee-contribution />
<voluntary-contribution />
<total-contribution />
</data>
</employer>
</scheme>
[...]
</body>
</return>
This is the sample of the data I am consuming
scheme-code emp-code pin empr-contr empyee-contr total total-vol-cont
10050 PR0000395010 PEN200386572133 54777.28 43821.82 108599.1 10000
10050 PR0000679771 PEN200629902715 65528.34 0 215528.34 150000
10050 PR0000007340 PEN200629902715 0 65528.34 215528.34 150000
10050 PU000035E001 PEN100786299723 10570.34 10570.34 21140.68 0
10050 TCF000615630 PEN100786299723 12060.15 12060.16 24120.31 0
10050 TCF000615630 PEN100786299723 12204.98 12204.99 24409.97 0
10050 PR0000615630 PEN100144364216 10945.19 13681.49 24626.68 0
10050 PR0000615630 PEN100453089112 14319.32 17899.15 32218.47 0
10050 PR0000615630 PEN200742682512 13116.33 16395.41 29511.74 0
10100 PRTEMP005022 PEN100940140007 792 990 1782 0
10100 PRTEMP005022 PEN100799131715 2375 2970 5345 0
10100 PRTEMP005022 PEN100799212715 831.6 1039.5 1871.1 0
In the body tag, I'd like to group the data first by the scheme-code and inside the code, group the data by the emp-code in that scheme and then by the data(pin, empr-contr,empyee-contr...) having the empr-code. The serial-no(int) for each data tag will be 0,1,2,3....T999 depending on the number of data tags in the parent employer tag. Please see further example below
<scheme>
<code>10050</code>
[...]
<employer>
<empr-code>PR0000615630</empr-code>
<data>
<serial-no>1</serial-no>
<pin>PEN100144364216</pin>
<employer-contribution>10945.19</employer-contribution>
<employee-contribution>13681.49</employee-contribution>
<voluntary-contribution>0.00</voluntary-contribution>
<total>32218.47</total>
</data>
<data>
<serial-no>2</serial-no>
<pin>PEN100453089112</pin>
<employer-contribution>14319.32</employer-contribution>
<employee-contribution>17899.15/employee-contribution>
<voluntary-contribution>0.00</voluntary-contribution>
<total>32218.47</total>
</data>
<data>
<serial-no>T9999</serial-no>
<pin>PEN200742682512</pin>
<employer-contribution>13116.33</employer-contribution>
<employee-contribution>16395.41</employee-contribution>
<voluntary-contribution>0.00</voluntary-contribution>
<total>29511.74</total>
</data>
</employer>
[...]
</scheme>
How can I generate it using XMLDocument or XMLWriter
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…