4
Answers

How to create C# class to hold xml data

Abhay Mhatre

Abhay Mhatre

16y
5.7k
1
Hell everyone,

Here I have 2 design problems.

I want to capture data from xml file and store it into database. I have thought of creating a C# class that will hold every node of xml and them I am thinking of using that class object to move back and forth through out my application. 

#1 . Now my first question is is there any other alternative way that I can use for this kind of work?

#2. I also haven't though of how I am going to store nodes that repeated several times in xml. Let me explain this question briiefly. 

Say I have following xml..

<root>
<family>
    <parents>
       <dad>Wayne</dad>
       <mom>Cathy</mom>
    </parents>
    <children>
       <child gen="boy">Lion</boy>
       <child gen="girl">Nikol</child>
    </children>
</family>

<family>
    <parents>
       <dad>Jiol</dad>
       <mom>Lindy</mom>
    </parents>
    <children>
       <child gen="boy">Michel</boy>
       <child gen="boy">Bob</child>
       <child gen="girl">Carol</child>
       <child gen="girl">Robin</child>
       <child gen="boy">Ryan</child>
    </children>
</family>
</root>


In above xml I can have one column for parents node that is I can have mom and dad column in SQL, but when I go to child the number of occurances are not fixed. In this case how should I create a database table to handle all the possible values....


Please help me put to solve this design problem....

Thank you in advanced.

Abhay Mhatre


Answers (4)
Next Recommended Forum