Solved

Working with Xml in Asp.Net C# 2008

Posted on 2008-06-20
4
476 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Formatting DateTime String Value 5 50
How does proportional-column-width work in xsl fo 4 38
vb.net convert long time to mm:ss 23 20
ASP and Looping Thru a XML Document 4 28
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

740 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