I have about 10,000 XML files where I need to convert them into SQL table.
However, here are the problems, each XML files has some variations between each other thus it is almost impossible for me to specify the element name. For example:
//XML #1
<color>Blue</color>
<height>14.5</height>
<weight>150</weight>
<price>56.78</price>
//XML #2
<color>Red</color>
<distance>98.7</distance>
<height>15.5</height>
<price>56.78</price>
//XML #3: Some of the elements have no value
<color />
<height>14.5</height>
<price>78.11</price>
//XML #4: Elements has parent/child
<color>
<bodyColor>Blue</bodyColor>
<frontColor>Yellow</frontColor>
<backColor>White</backColor>
</color>
<height>14.5</height>
<weight>150</weight>
<price>56.78</price>
With the example above, I should expect a table created with columns name: color, height, weight, price, distance (Because XML #2 has distance), bodyColor, frontColor, backColor.
Expected output:
XML# color height weight price distance bodyColor frontColor backColor
1 Blue 14.5 150 56.78 NULL NULL NULL NULL
2 Red 15.5 NULL 56.78 98.7 NULL NULL NULL
3 NULL 14.5 NULL 78.11 NULL NULL NULL NULL
4 NULL 14.5 150 56.78 NULL Blue Yellow White
In this case, NULL or empty value are acceptable.
These are just examples, there are at least 500 elements in each XML file. Also, even though I mentioned C# here, if anyone can suggest a better way of doing so, please let me know.