ASP.NET Dynamic Data brings major usability and RAD development changes to the existing ASP.NET data controls. RAD development is significantly increased by the use of a rich scaffolding framework. After you add a LINQ to SQL or Entity Framework data model to a project, you can simply register it with Dynamic Data. The result is a fully functional Web site. Full CRUD (create, read, update, and delete) operations are supported. The site includes filtering by foreign keys and Boolean fields; foreign keys are automatically converted to their friendly names. Smart validation is automatically available, which provides validation based on database constraints for nullable fields, data type, and field length. The DetailsView and GridView controls have been extended to display fields by using templates instead of by using hard-coded rules that are programmed in the controls. These templates are part of the project, and you can customize them to change their appearance or to specify which controls they use for rendering. This makes it very easy to make a change in one place in your site that specifies how to present dates for editing, as one example. FormView and ListView controls can implement similar behavior by using a DynamicControl object in their templates and by specifying which field in the row to display. Dynamic Data will then automatically build the UI for these controls based on the templates that you specify. Validation is significantly improved in the controls as well. The controls read metadata for a LINQ to SQL or Entity Framework data model and provide automatic validation based on the model. For example, if a column in the database is limited to 50 characters, and if a column is marked as not nullable, a RequiredFieldValidator control is automatically enabled for the column. (The controls also automatically support data-model-level validation.) You can apply other metadata to take further control over display and validation. In a nutshell this enables you to really quickly build data driven web-sites that work against a LINQ to SQL (and in the future LINQ to Entities) object model – and optionally allows you to-do this without having to build any pages manually.
Archive for the ‘.NET’ Category
VB 6.0 Migration
10 December 2009 | No Comments » | adminVB6 Migration Library
Visual Basic 6.0 runtime will be supported on Windows Server 2003 until June 2008 for Mainstream Support and June 2013 for Extended Support. The IDE will move out of extended support April 8, 2008.
Below are a series of links that relate to VB6 and VB6 Migration to VB.NET.
- VBRun remains the best resource site for VB6 professionals.
- Patterns and Practices – Upgrading VB6 to VB.NET
- VB6 Upgrade resource site for VB6 developers
- How to use the Visual Basic upgrade wizard. Useful for simple applications.
- New features in the Visual Basic 2005 Upgrade Wizard.
- Patterns and Practices has a good book on Upgrading VB6 applications to VB.NET. It provides some good architectural guidance in looking at the upgrade alternative options/approaches, processes, best practices, and proven techniques.
- There is a VB6 to VB.NET upgrade assessment tool that automatically analyses your VB6 application to determine what issues you need to address to be able to upgrade, it also provides information and guidance about how to address the issues, and metrics of your VB6 application as basis for costing/effort estimation.
- Microsoft’s Support Statement for VB6 on Windows Server 2008. They are commited to “It just works” compatability. The link contains the list of VB6 dll’s that are and are NOT supported on Vista and Windows Server 2008.
- Microsoft’s support statement for VB6, http://msdn2.microsoft.com/en-us/vbrun/ms788707.aspx
- Support Statement for Visual Basic 6.0 on Windows Vista, Windows Server 2008 and Windows 7. DLL’s that were not supported in Vista are still NOT supported on Windows 7
ASP to ASP.NET Migration Assistant:
The ASP to ASP.NET Migration Assistant is designed to help you convert ASP pages and applications to ASP.NET. It does not make the conversion process completely automatic, but it will speed up your project by automating some of the steps required for migration.
In this guide, you will find:
- Instructions on how to download and install the migration assistant and accompanying code sample
- An introduction to the ASP to ASP.NET Migration Assistant.
- A comprehensive set of white papers on technical conversion issues.
- Source code for a Web site before and after conversion.
- Extensive guidance on how to best leverage ASP.NET, including new best practices material from the Prescriptive Architecture Guidance (PAG) group.
This guide contains three sections
- Download and Install the ASP to ASP.NET Migration Assistant
Visit http://www.asp.net/migrationassistants/asp2aspnet.aspx and follow the instructions to download and install the ASP to ASP.NET Migrations Assistant and the accompanying code sample. - Using the ASP to ASP.NET Migration Assistant
Moving to ASP.NET is generally accomplished in two steps. First you port the existing ASP application to ASP.NET and then you can optimize the application to fully leverage the .NET Framework. This section covers the initial migration using the Migration Assistant to automate some of the steps. - Optimizing Your Migrated Site For ASP.NET
Sites migrated using the Migration Assistant can leverage the benefits of the .NET Framework, but there are still many optimizations that can be made to fully utilize the power of ASP.NET. This section describes how to optimize the ASP.NET site ported from ASP in the previous section.
MS WhitePaper:
Moving from Visual Basic to ASP.NET
With ASP.NET and Visual Studio .NET, creating Web applications and stand-alone Windows desktop applications are becoming near identical tasks. Explore how Visual Basic 6.0 developers can easily move their skills to the Web using ASP.NET.
Converting ASP to ASP.NET
An examination of a typical data-driven ASP application, and a discussion of the essential steps involved in porting that ASP application to ASP.NET.
.NET 1.1 to .NET 2.0 Migration FAQ
8 December 2009 | No Comments » | adminNET 1.1 to .NET 2.0 Migration FAQ
Q: “How much work will it take to move from 1.1 to 2.0 and how long will it take?”
A: The answer is “It depends”. Some applications move over with the simple click of a button, and others take a little more work than that.
Q: “Do you need to migrate at all?”
A: If it is an application that is still “alive” and moving forward, then the answer is “Yes, you should migrate.” then keep reading If you have a 1.1 application that is working just fine, and you don’t plan on modifying/updating it, leave it as it is and it should work just fine side by side.
Q: What happens when you load/run a .NET 1.1 application on a machine that has both 1.1 and 2.0 installed?
A:
| Application type | Computer with 1.1 | Computer with 2.0 | Computer with 1.1 and 2.0 |
| 1.1 stand-alone application (Web or Microsoft Windows client) | Loads with 1.1 | Loads with 2.0 | Loads with 1.1 |
| 2.0 stand-alone application (Web or Microsoft Windows client) | Fails | Loads with 2.0 | Loads with 2.0 |
| 1.1 add-in to a native application (such as Office or Internet Explorer) | Loads with 1.1 | Loads with 2.0 | Loads with 2.0 unless the process is configured to run against 1.1 |
| 2.0 add-in to a native application (such as Office or Internet Explorer) | Fails | Loads with 2.0 | Loads with 2.0 |
Given that .NET was designed for side-by-side usage since it first came out, that 1.1 application should run fine in a side-by-side environment. It’s the scenarios in bold that you need to really pay attention to with regards to testing. What will catch folks off-guard are the scenarios in the third row in the table. The gotcha is that you might not even be aware of what applications cause the third row scenarios.
The 2.0 framework is mostly backwards compatible with the 1.1 framework. Meaning, most 1.1 applications should run okay on the 2.0 framework. Therefore, the scenarios in bold should work out for you most of the time if you choose not to migrate your 1.1 application forward. But (and there is always a ‘but’), there are some breaking changes in the 2.0 framework.
Here’s where you can find out about breaking changes in the 2.0 Framework. Use this list ahead of time to analyze your 1.1 application and anticipate where issues might crop up:
http://msdn.microsoft.com/en-us/library/ms994364.aspx
Then, once you have a heads up on what could go wrong, test out the scenarios in the matrix where your 1.1 application could be loaded using the 2.0 framework. Here are some test scenarios to consider:
http://msdn.microsoft.com/en-us/library/ms994387.aspx
If your 1.1 application fails to run on 2.0 for whatever reason, and you still need to support the scenario in the last column of the third row, you can make some configuration changes to force the application to run using the 1.1 framework. Check these two links for more information:
- http://msdn.microsoft.com/en-us/library/s80xxs7s(VS.71).aspx
- http://blogs.digineer.com/blogs/tabraham/archive/2005/12/09/15.aspx
Q: I want to migrate my application from .NET 1.1 to .NET 2.0. Where do I start?
The quick and dirty answer: Back up your VS 2003/1.1 solution first!!! Then, open your Visual Studio 2002 or 2003 project/solution in Visual Studio 2005 or 2008. A conversion wizard will convert the project/solution to 2005. Compile the code, and you will now have a .NET 2.0 application!
The real answer: If you’re migrating a Windows Forms application, the majority of times, the quick and dirty answer above will be all it takes for you! If you’re migrating an ASP.NET web application, you should do a little homework before you open your .NET 1.1 project/solution in Visual Studio 2005 or 2008.
Let’s talk about non-web applications first. As I mentioned, most of the time, opening the application in Visual Studio 2005 or 2008 and running it through the conversion wizard should be all it takes. This will merely update the project files (.vbproj/.csproj) to work with 2005. It will not update your application code to take advantage of the new .NET 2.0 features. At this point, when you compile your existing 1.1 code, it will be compiled against the 2.0 framework. If the code doesn’t compile, check out the list of breaking changes in the 2.0 framework mentioned above and begin troubleshooting from there.
For migrating web applications, there can be more work involved since the project model for web applications has changed greatly in Visual Studio 2005 and 2008. Fortunately migration information is centraly located on MSDN’s ASP.NET migration center.
Tech Articles:
Common ASP.NET 2.0 Conversion Issues and Solutions
Solve some of the common conversion issues developers may face when upgrading from ASP.NET 1.x to 2.0.
What’s New in Web Development for Visual Studio 2005
Visual Web Developer continues to bring you the productivity benefits of the Visual Web Developer integrated development environment (IDE) while introducing a wide array of improvements.
Migrating from ASP to ASP.NET 2.0
Learn the concepts and tools you will need to develop applications in ASP.NET 2.0 coming from classic ASP. Explore the benefits of Microsoft’s newest Web technology and understand how to transition from ASP to ASP.NET 2.0.
ASP.NET 2.0 QuickStart Tutorial
The ASP.NET QuickStart is a series of ASP.NET samples and supporting commentary designed to quickly acquaint developers with the syntax, architecture, and power of the ASP.NET Web programming framework.
OAuth and .NET
13 November 2009 | 2 Comments » | adminOAuth is a new wave in the website security protocol or to be precise an API access delegation protocol’. OAuth allows a client application to obtain user consent (as access tokens) for executing operations over private resources on his behalf.
OAuth allows you to share your private resources (photos, videos, contact list, bank accounts) stored on one site with another site without having to hand out your username and password. There are many reasons why one should not share their private credentials. Giving your email account password to a social network site so they can look up your friends is the same thing as going to dinner and giving your ATM card and PIN code to the waiter when it’s time to pay. Any restaurant asking for your PIN code will go out of business, but when it comes to the web, users put themselves at risk sharing the same private information. OAuth here comes to the rescue.
If you want to know more about how OAuth works, you should read the following posts
- “Begginer’s Guide to OAuth – Part I”
- “Begginer’s Guide to OAuth – Part II – Protocol Workflow”
- “Begginer’s Guide to OAuth – Part III – Security Architecture”
Now, if we analyze the specification in more detail, we will see that the real purpose behind OAuth is to create a network of collaboration between applications. It will not be necessary anymore to keep all our stuff just in a single place, we can have for instance our pictures in a website, our contacts in another place and a third application making use of them, all these applications collaborating together.
Currently we hear OAuth being mostly associated with the social networking sites like Twitter, yahoo, google etc. However this is going to change in future, I see it being implemented in the cloud computing environment to provide more seamless access. Google has released its OpenID/OAuth implementation. This is a major step forward in the Interoperability field. The work that Google has released is very important and it will allow, for instance, that a user from Zoho Writer can use data from a Google Docs Spreadsheet and then make the result available in his Linkedin profile.
Similarly I think with Microsoft releasing its new cloud computing platform Azure. The OAuth definitely comes into play more so important than ever before.
Some of the OAuth .NET Faremwork Library available are :
- Alex Henderson (Aka Bittercoder) has written a pretty good OAuth library in .NET for implementing an OAuth consumer and service provider. The library is available here under a MIT license (do wherever you want with it), and it is very easy to use. Alex has definitively made a very good work.
- Madgex has released an open source OAuth library for .NET (released under the MIT License). Documentation and demos are available.
- C# Eran Sandler has contributed a basic C# class that performs signing.
- VB.NET Nicolas Tarzia has translated Eran Sandler’s C# library into VB.NET.
Here is some OAuth Implementation examples in .NET
- Pablo M. Cibraro (aka Cibrax) has given a great example of implementing OAuth Channel for WCF.
- For implementing OAuth in ASP.NET MVC
ORM in .NET
13 November 2009 | No Comments » | admin
Introduction
ORM, or object-relational mapping, is one of the tougher things to accomplish in modern, object-oriented programming languages. It involves moving away from the traditional data store paradigm: there is no (or very little) dedicated, pre-compiled code involved in reading/writing an object to/from the database or other backing store. Instead, the logic involved in accessing the backing store is determined at runtime using a combination of reflection and attributes that decorate the business objects in question. Many projects and frameworks have been created to try to address this concept, with varying degrees of success. What this article covers is a general introduction to ORM concepts, the approach that .NET 3.5 takes.
In the beginning…
Prior to .NET 3.5, you had several choices when it came to getting your business objects to and from the database:
- Roll your own – This means you don’t use any frameworks and don’t auto-generate any code. The database schema and the
.NETclasses are created by hand, as is the data access layer. While this will provide the ultimate level of customizability and performance, it’s tedious (involves copying a lot of boilerplate code), error prone, and difficult to maintain when the objects or the database schemas change. - Auto-generate the classes and the data access layer – This is where code generation tools like
CodeSmithorMyGenerationcome in: you point them at your database and it will generate the.NETclasses and the data access layer. Like option 1, this isn’t true ORM: you still have pre-compiled code responsible for accessing the database to read or write an object’s data. However, its automatic generation of the code is a step in the right direction, removing the error-prone human factor when creating the classes and the data access layer. - Use a true
ORMframework – There are several well-knownORMpackages available for previous versions of the.NETframework, includingNHibernateandGentle.NET. As mentioned previously,ORMremoves the dedicated data store code and inspects anobjectat runtime to determine what it needs to do to read/write it to/from the database. Attributes are used to decorate the class and its properties to give the framework pointers about where things go in the database. The actualSQLfor an operation is generated dynamically based on these attributes. There is often a code-generation component in these packages that generates the.NETbusiness object classes from the database schema, but no dedicated data access code is generated
Some Problems with ORM
So all this dynamic, runtime SQL generation stuff sounds great, right? Not so fast: ORM has several serious drawbacks. The first of these is performance, as you’re going to encounter a slowdown any time you bring reflection into the equation and start dynamically generating SQL. ORM will never be as fast as rolling your own: there’s no substitute to being able to hand-tweak your stored procedures and pre-compile all of the data access logic. Another drawback is that ORM doesn’t deal well with extremely complex databases. When designing complex databases with a lot of constraints and relationships spanning several tables, it’s often necessary to include intermediary tables to link various entities together that is great from a RDBMS standpoint, but doesn’t translate all that well to an object-oriented environment. This can lead to obtuse and difficult to understand auto-generated classes. Keep in mind that RDBMS and object-oriented environments are fundamentally different, and each includes its own set of design and performance considerations. What works in one environment is not necessarily optimal for the other environment. That being said, the upside to ORM in terms of maintainable, clean, and easy to understand code can be quite compelling, provided that it’s used correctly.
ADO.NET Entity Framework in .NET 3.5
ORM is all about and its potential pitfalls, let’s delve into how Microsoft approached this concept in .NET 3.5. It takes a different approach to the challenge of ORM by not focusing on slaving the object model to a relational model, but by instead giving us an entirely new way to access and query our data that’s not limited only to relational data. With this approach, the ORM capabilities of .NET 3.5 evolve almost as a side-effect instead of being the prime focus of this new data access scheme. The ADO.NET Entity Framework is designed to enable developers to create data access applications by programming against a conceptual application model instead of programming directly against a relational storage schema. The goal is to decrease the amount of code and maintenance required for data-oriented applications. Entity Framework applications provide the following benefits:
- Applications can work in terms of a more application-centric conceptual model, including types with inheritance, complex members, and relationships.
- Applications are freed from hard-coded dependencies on a particular data engine or storage schema.
- Mappings between the conceptual model and the storage-specific schema can change without changing the application code.
- Developers can work with a consistent application object model that can be mapped to various storage schemas, possibly implemented in different database management systems.
- Multiple conceptual models can be mapped to a single storage schema.
- Language-integrated query (LINQ) support provides compile-time syntax validation for queries against a conceptual model
LINQ in .NET 3.5
How do they do it? LINQ. It stands for Language INtegrated Query and Microsoft wants it to be THE way that you sift through data in the .NET framework. Its structure will be immediately familiar to anyone with experience writing SQL statements and it marries the simple yet powerful query syntax of SQL to the strong typing of an object-oriented language. The real kicker, however, is that it’s not limited to relational data: anything that implements the IEnumerable and IQueryable interfaces can be used with LINQ. Here’s a quick example so that you can get an idea of what it’s capable of:
01.List<string> elements = new List<string>() 02.{ 03. "Iridium", 04. "Einsteinium", 05. "Polonium" 06.}; 07.IEnumerable<string> results = from element in elements 08. where element.Contains("n") 09. select element;It’s just a simple search of a generic string list instance for elements that contain the letter “n”. Whereas before you would have had to accomplish this imperatively, that is, you would have had to write code to iterate over the collection and drive the search, you can now accomplish the same thing declaratively. Basically, you’re stating what you want to do instead of how to do it. While the syntax takes some getting used to, this approach is inherently less error-prone. It also bears mentioning that Intellisense is in full effect in the above sample, so you lose none of the “ease of use” features of Visual Studio when you employ LINQ.
.NET goes open source and cross platform with Mono
10 November 2009 | No Comments » | adminIn the last blog i talked about MonoDevelop an open source cross platform IDE for .NET development. This cross platform .NET development was only possible due to the Mono Framework.
Mono is a software platform designed to allow developers to easily create cross platform applications. It is an open source implementation of Microsoft’s .Net Framework based on the ECMA standards for C# and the Common Language Runtime. We feel that by embracing a successful, standardized software platform, we can lower the barriers to producing great applications for Linux.
The Components
There are several components that make up Mono:
C# Compiler – The C# compiler is feature complete for compiling C# 1.0 and 2.0 (ECMA), and also contains many of the C# 3.0 features.
Mono Runtime – The runtime implements the ECMA Common Language Infrastructure (CLI). The runtime provides a Just-in-Time (JIT) compiler, an Ahead-of-Time compiler (AOT), a library loader, the garbage collector, a threading system and interoperability functionality.
Base Class Library – The Mono platform provides a comprehensive set of classes that provide a solid foundation to build applications on. These classes are compatible with Microsoft’s .Net Framework classes.
Mono Class Library – Mono also provides many classes that go above and beyond the Base Class Library provided by Microsoft. These provide additional functionality that are useful, especially in building Linux applications. Some examples are classes for Gtk+, Zip files, LDAP, OpenGL, Cairo, POSIX, etc.
The Benefits
There are many benefits to choosing Mono for application development:
Popularity – Built on the success of .Net, there are millions of developers that have experience building applications in C#. There are also tens of thousands of books, websites, tutorials, and example source code to help with any imaginable problem.
Higher-Level Programming – All Mono languages benefit from many features of the runtime, like automatic memory management, reflection, generics, and threading. These features allow you to concentrate on writing your application instead of writing system infrastructure code.
Base Class Library – Having a comprehensive class library provides thousands of built in classes to increase productivity. Need socket code or a hashtable? There’s no need to write your own as it’s built into the platform.
Cross Platform – Mono is built to be cross platform. Mono runs on Linux, Microsoft Windows, Mac OS X, BSD, and Sun Solaris, Nintendo Wii, Sony PlayStation 3, Apple iPhone. It also runs on x86, x86-64, IA64, PowerPC, SPARC (32), ARM, Alpha, s390, s390x (32 and 64 bits) and more. Developing your application with Mono allows you to run on nearly any computer in existance (details).
Common Language Runtime (CLR) – The CLR allows you to choose the programming language you like best to work with, and it can interoperate with code written in any other CLR language. For example, you can write a class in C#, inherit from it in VB.Net, and use it in Eiffel. You can choose to write code in Mono in a variety of programming languages.
–courtesy mono project
MonoDevelop opens up Mac for .NET development
7 November 2009 | 1 Comment » | adminAs I said that I am a technology evangelist. I like new technology in .NET as well as open source. Other thing which I liked was Mac. But before MonoDevelop both were two different worlds. You could not develop a .NET application on a Mac OS X. MonoDevelop has solved most of my problem or you can say it is the new bridge between different platforms.
MonoDevelop is an opensource Integrated development environment for Linux platform, Mac OSX and Windows(to be supported in future). It allows you to develop software targeted to Mono and .NET framework. This IDE has feature like intellisense, source control integration and an integrated GUI and Web designer
MonoDevelop has recently launched the latest version of the IDE. To read more about it http://monodevelop.com/Download/MonoDevelop_2.0_Released.
If you’ve worked with Microsoft Visual Studio, you will see many similarities in MonoDevelop and will feel quite comfortable in the Mono environment. If you’re new to MonoDevelop and haven’t worked in Visual Studio, you’ll find that the learning curve is not very steep.
A new competitor for Visual Studio IDE…. eeh…lets see!!
XMLDocument Vs LINQ to XML
6 November 2009 | No Comments » | admin.NET as it had evolved has come up with different API to read and write XML data. If you are using .NET 3.0 and lower version you will have to use XMLDocument aka the classic DOM API. With .NET 3.0 Microsoft had launched Language Integrated Query(LINQ) and with this came one of the feature name the LINQ to XML.
LINQ to XML has a simple model for building XML documents by hand. Whether it be XML sources from a stream or file, or XML created on-the-fly in code there are only a few important types to know and understand. The main ones used in everyday activities are XDocument, XElement and XAttribute.
In this article we will talk about XDocument and XMLDocument.
Lets consider the following test data for our article
<root>
<child id=’123′/>
<child id=’234′/>
…
</root>
Reading the XML
XmlDocument.Load
XmlDocument.Load was the cleanest and easiest to understand. It is necessary that you must know XPath, although the fact is I like XPath. XmlDocument does have some security concerns with XPath injection. Here is how we code to load a document
private static void XmlDocumentReader(string fileName) {
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
XmlNodeList nodes = doc.SelectNodes(“//child”);
if (nodes == null) {
throw new ApplicationException(“invalid data”);
}
foreach (XmlNode node in nodes) {
string id = node.Attributes["id"].Value;
ProcessId(id);
}
}
Another way to query a single node is given below
XmlDocument doc = XmlDocument.Load(fileName);
XmlNode node = doc.SelectSingleNodes(“/root/child[@id=’123’")
LINQ to XML
LINQ to XML was also very easy to read and understand code. XDocument.Load does read the whole document into memory before returning. Due to feature of Lambda expression it has become very easy to traverse the xml document. The query syntax is easier than XPath or XQuery for developers who do not use XPath or XQuery on a daily basis. Here is the code I used to load and search the document:
private static void XDocumentReader(string fileName) {
XDocument doc = XDocument.Load(fileName);
if (doc == null | doc.Root == null) {
throw new ApplicationException("invalid data");
}
foreach (XElement child in doc.Root.Elements("child")) {
XAttribute attr = child.Attribute("id");
if (attr == null) {
throw new ApplicationException("invalid data");
}
string id = attr.Value;
ProcessId(id);
}
}
Another way to query a single node is given below
var xd = XDocument.Load(fileName);
var domQuery =
from c in xd.Descendants("child ")
where (string)c.Attribute("id") == "123"
Writing a new XML
Both the method almost looks similar.
XmlDocument
XmlDocument xmlDoc = new XmlDocument();
// Write down the XML declaration
XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0","utf-8",null);
// Create the root element
XmlElement rootNode = xmlDoc.CreateElement("root");
xmlDoc.InsertBefore(xmlDeclaration, xmlDoc.DocumentElement);
xmlDoc.AppendChild(rootNode);
// Create a new <child> element and add it to the root node
XmlElement parentNode = xmlDoc.CreateElement("child");
// Set attribute name and value!
parentNode.SetAttribute("ID", "01");
xmlDoc.DocumentElement.PrependChild(parentNode);
LINQ to XML
XDocument doc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XElement("root",
new XElement ("child", new XAttribute("id", "01")
)
);
Manipulating XML Data
XmlDocument
Here we have to struggle with manipulating the xml data. First take help of XPath to select the node and then use replace node to update it. Or use the feature of delete node and insert new node. Code is given below
XmlDocument doc = new XmlDocument.Load(fileName);
//Select the cd node with the matching title
XmlNode oldCd;
XmlElement root = doc.DocumentElement;
oldCd = root.SelectSingleNode("/root/child[id='1']“);
XmlElement newCd = doc.CreateElement(“child”);
newCd.SetAttribute(“id”,2);
root.ReplaceChild(newCd, oldCd);
//save the output to a file
doc.Save(fileName);
LINQ to XML
Here the code is very simple to write and understand. The coding time is also very less.
var xd = XDocument.Load(fileName);
var domQuery =
from c in xd.Descendants(“child “)
where (string)c.Attribute(“id”) == “123″
domQuery.Attribute(“id”).Value = 1
xd.save(filename)
Conclusion
Overall speaking both the API’s are equally powerful. However LINQ has made it little bit easier for developer to work with XML Data. I would say if you are using .NET 3.5 and higher you should rather go with LINQ To XML.