我有一个包含基本地址信息的 datagridview 表。
从这里我想创建一个包含所有地址的 xml 文件。但我需要根据国家订购它们。所以“地址”标签应该首先填写来自 Country1 和 country2 等的所有客户。
编辑: 我已经把文件写得井井有条,但我需要按国家/地区对地址进行分组。这就是我卡住的地方。
下面是一个示例,说明它的外观仅用于说明。真正的问题是如何根据数据网格行中的国家划分部分
<?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>