C
c#
I have a typed-dataset of items that need to be written to an xml file
in a specific format. Writing the Xml file is the easy part. How
difficult is it to write an output with the following format:
<root>
<productGroup productGroupId="1">
<product productId="1" price="2.00" />
<product productId="4" price="3.42" />
<product productId="6" price="0.90" />
</productGroup>
<productGroup productGroupId="2">
<product productId="7" price="2.00" />
<product productId="8" price="3.42" />
<product productId="9" price="0.90" />
</productGroup>
</root>
For each productGroup node I would like to have 3 products. The
productId's and price are being pulled from the database. There are
usually 20-25 productGroupId's so I need to have an outer loop from 0
< 20-25 ( exact number pulled from database as well ) as well as a
loop that counts how many products are added to each productGroup.
For an example let's say that there are 60 products and 20
productGroups that need to be populated. This makes for a nice number
of 3 products per productGroup.
I would also need the functionality to accommodate 59 products and
maybe 22 productGroups. This means that productGroups 1 - 19 would
have 3 items each, 20 would have 2, and 21 & 22 would have 0.
How difficult would it be to pull this off?
in a specific format. Writing the Xml file is the easy part. How
difficult is it to write an output with the following format:
<root>
<productGroup productGroupId="1">
<product productId="1" price="2.00" />
<product productId="4" price="3.42" />
<product productId="6" price="0.90" />
</productGroup>
<productGroup productGroupId="2">
<product productId="7" price="2.00" />
<product productId="8" price="3.42" />
<product productId="9" price="0.90" />
</productGroup>
</root>
For each productGroup node I would like to have 3 products. The
productId's and price are being pulled from the database. There are
usually 20-25 productGroupId's so I need to have an outer loop from 0
< 20-25 ( exact number pulled from database as well ) as well as a
loop that counts how many products are added to each productGroup.
For an example let's say that there are 60 products and 20
productGroups that need to be populated. This makes for a nice number
of 3 products per productGroup.
I would also need the functionality to accommodate 59 products and
maybe 22 productGroups. This means that productGroups 1 - 19 would
have 3 items each, 20 would have 2, and 21 & 22 would have 0.
How difficult would it be to pull this off?