Solved

Working with Xml in Asp.Net C# 2008

Posted on 2008-06-20
4
475 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
4 Comments
 
LVL 21

Accepted Solution

by:
naspinski earned 250 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

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…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

791 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