Solved

Working with Xml in Asp.Net C# 2008

Posted on 2008-06-20
4
472 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now