I have a DataSet which returns three rows say A,B,C. Data will be in the Following format.
1 5 9
2 6 10
3 7 11
4 8 12
Now i want to convert this into xml in the below mentioned format..

<chart showValues='0' caption='Cost Analysis' numberPrefix='$' xAxisName='Quarters' yAxisName='Cost' useRoundEdges='1' >   
      <category label='1'/>      
      <category label='2'/>     
      <category label='3'/>    
      <category label='4'/>  
 <dataset seriesName='Variable Cost'>        
     <set value='5'/>         
     <set value='6'/>          
     <set value='7'/>        
     <set value='8'/>       
 <dataset seriesName='Budgeted cost' renderAs='Line'>       
     <set value='9'/>       
     <set value='10'/>      
     <set value='11'/>      
     <set value='12'/>      

Could anyone assist me with is.
Any answers are appreciated.


Recommended Answers

All 2 Replies

The DataSet class does offer direct serialization to/from XML files, however I'm assuming your DataSet doesn't necessarily correlate to your XML schema. So, take a look at the XmlDocument class. Basically you can create XML elements and attributes using the XmlDocument's Create...() methods, than use AppendChild() on the appropriate object to build its structure. Finally use XmlDocument.Save() to generate the file.

commented: Good suggestion. +15

Hi, check for solution here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.