Click here to Skip to main content
16,020,080 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

My requirement is to produce xml file from Database. There are many tables in the DB which have relation to each other,I have to make use of the tables and then create a xml file from them.
Eg:

Table1 has 4 columns
ApplicationId,
ApplicationName,
ApplicationType,
Application Description,



Table2 has 4 columns

ApplicationDataSourceID,
ApplicationID,
title,
unit



As such there are many tables but i have mentioned only 2, I need to make use of them and generate an xml file, the sample of xml file is as below:

<aamp>
  <application name="Sustainability mapping tool" type="narativeMap">
    <reportdisplay>
      <reports id="0" iconfile="none.png" highlightcolour="0x84c201">
        <title permaLink="World View"><![CDATA[World View</title>
        <reports id="1" iconfile="none.png" highlightcolour="0xa1cc28" filtertype="0">
          <title permaLink="Our-operations"><![CDATA[Our operations</title>
          <datasources>
            <datasource id="1" />
          </datasources>
        </reports>
        <reports id="3" iconfile="none.png" highlightcolour="0x009f00" filtertype="2">
          <title permaLink="air-emissions"><![CDATA[Air emissions</title>
          <datasources>
            <datasource id="1" />
          </datasources>
        </reports>

         </reports></reportdisplay>....</application></aamp>

.
.
.
.
. and so on..

I am using ASP.NET, Can anyone suggest a nice and easy idea to proceed?
Posted
Updated 17-Jan-11 20:19pm
v2

1 solution

Try This..,

Make a database Query with relations which tables you want like..,
select * from table1,table2 where table1.id=table2.id


Execute your query using dataadapter and load into the dataset.

use the below code for save dataset as xml.
DataSet myds = new DataSet();
......Readdata using dataadpter
.......fill in To dataset
    myds.WriteXml ("c:\\test.xml");
 
Share this answer
 
Comments
angelvarun 18-Jan-11 2:49am    
Hi Rajesh,
Thanks for the reply. But i feel that attributes will be ignored in this way, by attributes i mean , if you see the reports node there are attributes like iconfile and highlightcolor.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900