0

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 ?

2
  • Serialize the XML files into PERSON objects, save the objects to a DB with a unique id. When you need to retrieve the data again simply instantiate the returned records from DB as Person Objects. Commented Jan 7, 2016 at 11:44
  • SQL Server if it is your engine, can do it for you Commented Aug 14, 2017 at 17:13

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.