Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Working with Xml in Asp.Net C# 2008

Posted on 2008-06-20
4
Medium Priority
?
491 Views
Last Modified: 2008-11-21
What are the advantages of storing data in Xml file over database like Sql server 2005? And how to access xml file's data in asp.net C# 2008?
0
Comment
Question by:ShreyaTrivedi
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
naspinski earned 1000 total points
ID: 21830121
It (xml) really is just a different way to access your data.  It can be a bit more cumbersome if you are well versed in SQL, but even that is changing with LINQ (becoming a lot easier).

To me the main advantage of using XML is pure portability and no need for a SQL server.  You just move the files along with your program and you are good to go.  No install of anything.

On the other hand, for very large datasets, sql will be faster.  But for smaller (but still pretty big) sets, you will not even notice a difference and xml is sometimes even faster (cuts out a transport layer).

As I said, accessing XML has become much easier in the recent past.  Here is an example where I am getting all the parent elements which have a descendant of "categoryName".  The syntax might seem a little strange, but it is very simple once you get used to it.  This is using linq:
//C#
XElement x = XElement.Load(Server.MapPath(".") + "\\App_Data\\offers.xml");//get your file
//grab your categories
var AllOfferDetails = from p in (from q in x.Descendants("CategoryName") select q) where p.Value.Equals("No Annual Fee") select p.Parent.Parent;

Open in new window

0
 
LVL 21

Expert Comment

by:naspinski
ID: 21830133
I meant to say that in that example above it is getting the parents of all the CategoryName elements which the value is "no annual fee"
0
 

Author Comment

by:ShreyaTrivedi
ID: 21832019
I am totally new to Xml. So I wanted your help in -
I am making a ShareMarket web application.
I have a table containing clients information (ClientMaster). For each client (record), I have to maintain a table which will contain the scrips selected by him. I have thought of using xml for maintaing this table of scrips. So whenever I generate any report, I have to first check whether the scrips generated in report belong to the table of scrips corresponding to that client.
What should be the structure and how should I work with xml in this case?
And can I use Sql and Xml together ? I mean in my case, I will storing clients information in a table of sql and then can I store the scrips for the clients in xml?
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question