Sairam Soham

Sairam Soham

  • NA
  • 47
  • 28.8k

Design question about generation of hierarchial xml

Feb 18 2015 6:29 PM
Objective is to generate hierarchial xml



Input data is in the form of spreadsheet.


Which has colums H1, H2, H3 H4, H5, startdate,  enddate, height, width, phases and rating


I want to generate hirerichial xml

H1
H2
  H3
   H4
     H5

That means H4 is parent of H5, H3 is parent of H4 and so on......


A format of an xml will be

<SetEquipment   H1Id=<variable H1 from excel>   type='H1'>
  <Address height=<variable height>  width =<variable width>  />

<SetEquipment  H2Id=<Variable H2 from excel>  type ='H2'>
    <SetParentEquipment  ParentEquipmentId=<variable H1 from excel> type='H1'>
       <ParentLinkRange Start=<Variable startdate from excel> End=<Variable enddate from excel> />
    </SetParentEquipment>
     <Address height=<variable height from excel> width=<variable width from excel> />
</SetEquipment>


<SetEquipment  H3Id=<Variable H3 from excel>  type ='H2'>
    <SetParentEquipment  ParentEquipmentId=<variable H2 from excel> type='H2'>
       <ParentLinkRange Start=<Variable startdate from excel> End=<Variable enddate from excel> />
    </SetParentEquipment>   
</SetEquipment>


<SetEquipment  H4Id=<Variable H4 from excel>  type ='H4'>
    <SetParentEquipment  ParentEquipmentId=<variable H3 from excel> type='H3'>
       <ParentLinkRange Start=<Variable startdate from excel> End=<Variable enddate from excel> />
    </SetParentEquipment>
    <TransformerAttributes RatingKVA=<Variable rating from excel> />    
</SetEquipment>


<SetEquipment  H5Id=<Variable H5 from excel>  type ='H5'>
    <SetParentEquipment  ParentEquipmentId=<variable H4 from excel> type='H4'>
       <ParentLinkRange Start=<Variable startdate from excel> End=<Variable enddate from excel> />
    </SetParentEquipment>
    <SPAttributes NumberOfPhases=<Variable phases from excel> />   
</SetEquipment>


In Visual studio 2012
I am planning to get a data from spreadsheet into a dataset

Create the following classes
SetEquipment
SetParentEquipment
Address
TransformerAttributes
SPAttributes

using the namespace system.linq to generate xml

Question:

If anyone has any suggestion for better design this can be done I am very much interested

Thanks