how to create XML using DataSet having more then one table?
-
Dear Friend, I have four DataTable Name "Table 1", "Table 2", "Table 3" and "Table 4" this table contain two rows each as given below Data in "Table 1" ID 1 2 Data in "Table 2" ID Name 1 ABC 2 XYZ Data in "Table 3" ID Date 1 01/01/2009 2 02/01/2009 Data in "Table 4" ID Value 1 AAA 2 XXX This all table added in one DataSet related with each other using Relations with ID Column. Now when i create XML file using this DataSet it Gives me in sequence as given below. <?xml version="1.0" standalone="yes" ?> <Data Set> <Table 1> <ID>1</ID> </Table 1> <Table 1> <ID>2</ID> </Table 1> <Table 2> <Name>ABC</Name> </Table 2> <Table 2> <Name>XYZ</Name> </Table 2> <Table 3> <Date>01/01/2009</Date> </Table 3> <Table 3> <Date>02/01/2009</Date> </Table 3> <Table 4> <Value>AAA</Value> </Table 4> <Table 4> <Value>XXX</Value> </Table 4> </Data Set> The problem is the sequence i want the same data in following sequence <?xml version="1.0" standalone="yes" ?> <Data Set> <Table 1> <ID>1</ID> </Table 1> <Table 2> <Name>ABC</Name> </Table 2> <Table 3> <Date>01/01/2009</Date> </Table 3> <Table 4> <Value>AAA</Value> </Table 4> <Table 1> <ID>2</ID> </Table 1> <Table 2> <Name>XYZ</Name> </Table 2> <Table 3> <Date>02/01/2009</Date> </Table 3> <Table 4> <Value>XXX</Value> </Table 4> </Data Set> Is this Possible? or there is another way to do this? Please help me. Thanks and Regards in advance Sasmi
-
Dear Friend, I have four DataTable Name "Table 1", "Table 2", "Table 3" and "Table 4" this table contain two rows each as given below Data in "Table 1" ID 1 2 Data in "Table 2" ID Name 1 ABC 2 XYZ Data in "Table 3" ID Date 1 01/01/2009 2 02/01/2009 Data in "Table 4" ID Value 1 AAA 2 XXX This all table added in one DataSet related with each other using Relations with ID Column. Now when i create XML file using this DataSet it Gives me in sequence as given below. <?xml version="1.0" standalone="yes" ?> <Data Set> <Table 1> <ID>1</ID> </Table 1> <Table 1> <ID>2</ID> </Table 1> <Table 2> <Name>ABC</Name> </Table 2> <Table 2> <Name>XYZ</Name> </Table 2> <Table 3> <Date>01/01/2009</Date> </Table 3> <Table 3> <Date>02/01/2009</Date> </Table 3> <Table 4> <Value>AAA</Value> </Table 4> <Table 4> <Value>XXX</Value> </Table 4> </Data Set> The problem is the sequence i want the same data in following sequence <?xml version="1.0" standalone="yes" ?> <Data Set> <Table 1> <ID>1</ID> </Table 1> <Table 2> <Name>ABC</Name> </Table 2> <Table 3> <Date>01/01/2009</Date> </Table 3> <Table 4> <Value>AAA</Value> </Table 4> <Table 1> <ID>2</ID> </Table 1> <Table 2> <Name>XYZ</Name> </Table 2> <Table 3> <Date>02/01/2009</Date> </Table 3> <Table 4> <Value>XXX</Value> </Table 4> </Data Set> Is this Possible? or there is another way to do this? Please help me. Thanks and Regards in advance Sasmi
The only way to make that happen is to write your own serialization code for the dataset. Frankly, I wonder why every newbie who sees XML immediately thikns it's a database. It's not. XML is a data storage and transfer markup language. It is most assuredly NOT a good candidate for a database engine.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008