I have about 10,000 XML files where I need to convert them to an SQL table.
However, here are the problems, each XML file has some differences, so it is almost impossible for me to specify the name of the element. For instance:
//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>
In the example above, I should expect a table created by a columnsname: color, height, weight, price, distance(as XML # 2 has a distance) bodyColor, frontColor, backColor.
Expected Result:
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 an empty value is allowed.
These are just examples; there are at least 500 elements in each XML file. Also, although I mentioned C # here, if someone can suggest a better way to do this, let me know.