I have a very complex task – create a software that imports XMl files to MSSQL database. There is one serious problem – each file has different structure than datatable. Example :
DATABASE:
It has columns like : ImageURL, Title, Content
XML:
Each XML file is different , I’ll give you two examples :
-
<contents> <ImageURL>www.123.com/image.png</ImageURL> <Title>Some text</title> <Content>Content of item</Content> </contents> <contents> <ImageURL>www.123.com/image.png</ImageURL> <Title>Some text</title> <Content>Content of item</Content> </contents>
2.
<item imageURL="url" title="title" content="content">
Is there any open source solution to this ?
* UPDATE *
I forgot to let you know that I will be using this code with an ASP.NET application in following steps:
- The user selects the url of the XML document which he wants to import
- The user would selectthe tags he wants to import to the database in GUI
- in code behind, rule for importing current file will be created and stored to database .
Any tips/tricks how to achieve this in the most simple way ? if you don’t have source code, please give me some hints. thanks
BE AWARE THAT EACH FILE HAS DIFFERENT STRUCTURE
You need to figure out the different version you have and write some code to handle each xml-structure.
You can do like this in SQL Server
1:
Result:
2:
Result:
3.
Result:
4.
Result: