0

I have a very, very, very old web project created in .NET 1.1 to which I want to upgrade to the latest .NET framework 4.7 so I could take advantage of its many benefits including performance. I've read several similar posts here but most of them are from 2009 to 2012 and may not be applicable to today's technology.

So far I've read about:

  • Dataset to XML
  • FOR XML
  • LINQ
  • and good ol' System.XML

In my experience, I've only tried System.XML which is what I used in my 1.1 code.

In your expert opinion and/or experience, which of these should I use? Or is there any other way to display my database query results as XML other than those listed above?

Notes on my project:

  • this is a personal project to practice my programming skills (which I haven't been able to practice for a long time now)
  • DB query is actually a stored procedure that can display up to 1000 rows of result
  • DB is SQL Server 2008 (no money to upgrade :) ); code is in c#
  • this is a web project that mainly displays DB query as XML so no need to save the XML on disk
  • it should be able to display the result in less than 5 seconds

I just want to know where to start, which technology you think is the best, so I could focus my readings on that. Right now I'm just confused and overwhelmed with the number of options I have.

Thanks very much.

Ramone
  • 11
  • 3
  • If the original code was written in c# then you should still use c#. c# will support xml with either library class XmlDocument or XDocument ( I prefer 2nd). c# also has a library SqlClient which will connect to SQL Servers 2008. You can download for free from msdn SQL Server Express 2014 which give most of the functionality as the full version – jdweng Aug 17 '17 at 09:38
  • @jdweng yes, it was written in c# and I have no plan on using other programming language. I edited my question to avoid confusion, thank you for pointing it out. I'm actually using XmlDocument, you think I should upgrade to XDocument then? thanks! – Ramone Aug 17 '17 at 09:42
  • XDocument requires less instructions than XmlDocument and is more concise making it easier to understand the code. XDocument also has more methods to extract data. If you already have working code you may not want to convert. – jdweng Aug 17 '17 at 10:06
  • Thank you, @jdweng! I would certainly consider using XDocument for this. I should add it to my reading list :) – Ramone Aug 17 '17 at 11:08

1 Answers1

0

SQL Server has got some great abilities to deal with XML natively. With v2008 you can use FOR XML PATH.

DB is SQL Server 2008 (no money to upgrade :) )

You might use the free Express versions...

What you really need, depends on what you want to do with the XML. If your only need is, to create an XML from data stored in your rdbms, I'd clearly use SQL Server directly... If you want to modifiy your XML, you might use XSLT.

C# will easily take this XML directly into XmlDocument or XDocument and allow you any kind of reading / modifying... (if needed)

Shnugo
  • 66,100
  • 9
  • 53
  • 114
  • Thanks! My project is actually using XmlDocument and I'm thinking I should upgrade to something like Linq for better performance and what not but I'm not really sure. I thought XmlDocument is old (forgive me if it's not) and there are better options other than that? It seems though that my understanding is incorrect. – Ramone Aug 17 '17 at 09:46
  • @Ramone Do I understand you correctly? You want to read some data, which is stored in your DB. You want to get this as XML and use this somewhere in your application? In this case you should create the XML directly within SQL Server. – Shnugo Aug 17 '17 at 09:58
  • Yes, that's correct. If I create the XML directly within SQL Server, I'm worried about the DB server's performance considering it can get up to a thousand rows of result. Say, for example, this is a commercial project with 100 users simultaneously using it, would that still be okay, creating the XML directly within SQL Server? – Ramone Aug 17 '17 at 11:06
  • Probably yes... But read [Race your horses](https://ericlippert.com/2012/12/17/performance-rant/) – Shnugo Aug 17 '17 at 11:11