0

I have a datagridview table with basic address information.

From this I want to create an xml file with all the addresses in it. But I need to order them based on the country. So the "Address" tag should first be filled with all customers from Country1 and than country2 etc.

Edit: I allready have the file writen in good order, but I need to group the address by country. And thats where I get stuck.

Below is an example of how it could look like just for illustration. The real question is how to part the sections based upon the country in the datagrid rows

<?xml version="1.0" encoding="utf-8"?>
<Customers>
 <Address>
  <Addressfield1>aaa</Addressfield1>
  <Addressfield2>bbb</Addressfield2>
  <Addressfield3>ccc</Addressfield3>
  <Country>Country1</Country>
 </Address>
 <Address>
  <Addressfield1>ddd</Addressfield1>
  <Addressfield2>eee</Addressfield2>
  <Addressfield3>fff</Addressfield3>
  <Country>Country1</Country>
 </Address>
 <Address>
  <Addressfield1>ggg</Addressfield1>
  <Addressfield2>hhh</Addressfield2>
  <Addressfield3>iii</Addressfield3>
  <Country>Country2</Country>
 </Address>
 <Address>
  <Addressfield1>jjj</Addressfield1>
  <Addressfield2>kkk</Addressfield2>
  <Addressfield3>lll</Addressfield3>
  <Country>Country2</Country>
 </Address>
</Customers>
Giancarlo
  • 377
  • 2
  • 6
  • 16

0 Answers0