Click here to Skip to main content
13,043,898 members (47,887 online)
Rate this:
Please Sign up or sign in to vote.
Hi every body.
Can use a Xml file for small mvc3 website?It have a Log in for edite delete ,and have pages for show news.
Posted 16-Apr-13 7:22am
learner'sbug 16-Apr-13 13:35pm
what do you want to use XML for ?
Sergey Alexandrovich Kryukov 16-Apr-13 14:53pm
I think it's clear. Please see my answer as well.
ryanb31 16-Apr-13 13:55pm
I don't think you should but of course you can write code to interface with xml. You'll have to do all the code though.
Sergey Alexandrovich Kryukov 16-Apr-13 14:53pm
This is extremely simple; everything is already done in .NET FCL. Please see my answer.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If your XML file is small enough to keep all the data in memory, this is a simple easy way to implement a kind of a database; and you would enjoy the huge benefits of purely object-oriented database, no mapping code. If this is not the case, however, such approach would be very awkward, and I would strongly discourage it, recommend some RDBMS, which could be open-source and more or less light weight.

That said, if using XML-based in-memory object-oriented database, first thing you should require is total isolation of storage from database functionality. Your database should be some object graph of general shape (first of all, you should not assume it is a tree), and the storage should be 100% agnostic of data types. These primary goals are fully satisfied with Data Contract:[^].

Please see my past answers where I advocate this wonderful approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^].

Note that you won't need to work with XML manually. Your object graphs will be stored in full and later restored in memory. Circular dependencies (remember, I mentioned that the object graph is not required to be a tree), the approach will still perfectly work. Besides, you can easily evolve the database schema and provide backward compatibility with files created in earlier versions of your software.

If the main criterion (all-database-in-memory) cannot be guaranteed, I would say that the effort would not worth the effort, not at all. In this case, opt for RDMBS. Review this set:[^],[^].

Good luck,
Maciej Los 16-Apr-13 15:35pm
Sergey Alexandrovich Kryukov 16-Apr-13 15:49pm
Thank you, Maciej. (Well, I assumed that OP knows what "RDBMS" means, but thank you again for a link.)
+5! beautiful
Sergey Alexandrovich Kryukov 16-Apr-13 18:01pm
Thank you very much, José.
learner'sbug 16-Apr-13 17:48pm
great answer.. +5
Sergey Alexandrovich Kryukov 16-Apr-13 18:01pm
Thank you very much.
abbaspirmoradi 17-Apr-13 3:41am
this is greate and very helpful for me.thanx Sergey.
Sergey Alexandrovich Kryukov 17-Apr-13 11:27am
You are welcome. Will you accept the answer formally (green button) then?
abbaspirmoradi 18-Apr-13 10:45am
My pleasure sir.
Sergey Alexandrovich Kryukov 18-Apr-13 10:54am
Good luck, call again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 16 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100