Muffin
Muffin

Reputation: 791

ASP.NET MVC importing XML files to Database

I have several hundreds of XML files with something similar to following format but with lot more objects and elements inside.

<?xml version="1.0" encoding="utf-8"?>
<Person Version="3.13.12.0" Type="Design">
    <Input>
        <InputClass1>
            <elem1>Value</elem1>
            <elem2>Value</elem2>
        </InputClass1>
        <InputClass2>
            <elem1>Value</elem1>
            <elem2>Value</elem2>
        </InputClass2>
        <InputClass3>
            <elem1>Value</elem1>
            <elem2>Value</elem2>
        </InputClass3>

    </Input>
    <Output>
        <Type1>
            <elem1>Value</elem1>
            <elem2>Value</elem2>
        </Type1>
        <Type2>
            <elem1>Value</elem1>
            <elem2>Value</elem2>
        </Type1>
        <Type3>
            <elem1>Value</elem1>
            <elem2>Value</elem2>
        </Type3>
        <Type>
            <elem1>Value</elem1>
            <elem2>Value</elem2>
        </Type3>
    </Output>
</Person>

Each file has a unique file name in my case. Users may replace the file. So previous version should be recorded. I have a ASP.NET MVC(API) web project. What would be the best way to record these files and query them from MVC/API controller ?

Upvotes: 0

Views: 1310

Answers (1)

user586399
user586399

Reputation:

I think best way is integrating your app with a SQL Server database, since SQL Server does have its own powerful engine to query and manipulate XML. So you create stored procedures and invoke them from your asp.net app (with ADO.NET)

See this sql server xml tutorial

Another Choice would be using Linq to manipulate xml.

Upvotes: 1

Related Questions