Basic Search  Advanced Search   
Topics Resources Free Library Software XML News About Us
  You are here: home Info Bank Articles » XML and .NET Tuesday, 14 August 2007

Back to Articles Page      


XML and .NET

  • Introduction
    Last year in July, at PDC, Microsoft announced .NET (dotNet). The .NET Framework Beta 1 is being evaluated (and appreciated) by developers all around the globe. The good news is that, this time Microsoft has restrained itself from making many proprietary technologies or API's and has heavily used some standard internet technologies which are in use today. Out of these, XML is one of the most important component in the .NET Platform. Recognizing the simplicity and power of XML in representing and transmitting data, it have been effectively harnessed in the .NET Platform. Support for XML and related technologies like DOM Level 2 Core, XPath 1.0, XSLT 1.0, XML Schemas (XSD), and the Simple Object Access Protocol (SOAP), has been in-built in .NET from ground up. The XML API in .NET is extensive and provides a wide array of types (classes) to manipulate with XML and related technologies very easily, effectively and with a significant gain in performance. Seeing this trend one thing that can be said definitely is, that if you are a programmer on the .NET, it goes without saying that you need to understand and express XML. Let's examine a few areas where XML has been used in .NET.

  • Applications
    The .NET Platform has been set up to answer the woe's of programmers suffering from code interoperability, scalability and some problems like DLL hell, extensive registration of components, etc.

    .NET calls an end to all the above problems. The code written on the .NET is interoperable to the extent that you can make a Type (class previously) in a programming language like Visual Basic and extend on it in C#! This kind of interoperability between languages running on the .NET help the programmers to incorporate components written in different languages which specialize in different programming functions and build a scalable model. To eradicate the problem of DLL hell , Microsoft has introduced self-describing and versionable assemblies which has metadata in its heart. Metadata, is very important since it contains all the information needed to describe and use a particular assembly. This helps in writing versionable, type safe and side by side execution of different versions of the same DLL.

    The deployment process of .NET applications has been simplified to the maximum. This means you no longer need to register and of the components in the registry! Deployment is as simple as copying the files to the clients hard drive, to uninstall just delete these files . If you programmed in C/C++ during the time of Win 3.xx, you might remember that the program setting were stored into text files with the extension ".ini" . With the advent of Win9x onwards the trend was to store the program settings into the Windows Registry. The .NET programmers have now taken up XML to store their program settings. This has two benefits, one being that data in a XML file makes sense and secondly it removes the dependency on the Windows Registry making deployment faster and easier.

    To provide power and security in the hands of administrators to modify the security, accessibility and working of .NET Applications, .NET has introduced the concept of "Configuration Files" for the administrator. Configuration files are XML formatted files, saved with the application name and ".cfg" as an extension. Configuration files help the administrator over-ride the security and behavior of the applications.

  • Programming Languages
    With .NET, C# (C Sharp), a new programming language, was announced, as a preferred programming language for .NET platform. Also VB.NET and Managed C++ were (re-)introduced. The CLR (Common Language Runtime) which specifies the common type libraries to be used by all programming languages on the .NET Platform has full support for XML. The special Namespace reserved for XML is "System.Xml". This namespace has many types to read, write and manipulate XML data. Since the CLR natively supports XML, there is guaranteed ease of use and support of XML in all the languages that will run on .NET platform.

    A nice programmer always documents the code, with proper comments. C# has introduced a new style of comments specially for documenting the code. During compilation with the "/doc" switch a XML file is generated which contains the documentation provided by the programmer while writing the code. This XML file can later be consumed by any XML aware system to provide the user with an efficient documentation. For instance, a stylesheet (XSL) can be applied to this generated XML to build a nice web document, describing the code comments.

    ASP.NET is not just an upgrade to ASP 3.0, but its a complete makeover for ASP! XML is tightly coupled within the ASP.NET model. The Web Configuration file "config.web" which contains the settings for the current Virtual Directory and "Global.asa" which is the Global Application level configuration file, are both XML formatted. Since now ASP.NET supports scripting in all .NET languages, which actually get compiled, not interpreted at runtime, so all the benefits that the programming languages have, automatically get passed on to ASP.NET.

    To enhance the scalability and stability within the .NET languages, there was a need to design a very reliable and strong Data Access component, since majority of the applications deal with databases in some form or the other. The result is ADO.NET. It has support for backward compatibility to the previous ADO model. ADO.NET has XML in its heart. ADO.NET supports both, hierarchical and relational data models. You can get a classic forward-only ADO styled cursor with DataReader component or the new disconnected in-memory representation of your data with the DataSet object. The DataSet object stores the database, tables, schemas and relations just as your database does, only difference being that the DataSet object is in-memory so its very fast. The DataSet object and other Data Access components have full support to directly read/write XML formatted data, XML schema based on the W3C standard, XSD and XPath. Also many other enhanced components are provided to make efficient use of every aspect of XML.

  • Web Services
    Web Services are "applications delivered as Service on the Web". With .NET, the Web Services have been integrated with the ASP.NET model, which makes the use and deployment of Web Services as easy as that of ASP.NET. Web Services, instead of having its own communication protocol, uses HTTP as its carrier of messages. The Web Service Interface can be strictly defined in the terms of Messages the Web Service accepts and generates. Messages in Web Services are SOAP encoded XML documents. Again to gain the description about the Web Services, we use the WSDL (Web Service Description Language) grammar file which is in XML format. Then there is the Discovery file (.DISCO) and the UUDI file which help you to locate and index various Web Services on the Internet, which too are XML formatted. It wouldn't be a overstatement if I would say that without XML, Web Services cannot function. Although this does not mean that to use and write Web Services require deep knowledge of XML. The current model of Web Services on the .NET Platform does its best to hide its deep functionality and make it easy to write Web Services.

  • Summary
    In this short article, we learned how .NET natively supports and utilizes XML. Almost, all aspects of .NET use XML in one form or the other. To utilize .NET services, it is good to have understanding of XML and it's related standards. In the future articles in this series, we'll take a detailed look at .NET's support for XML.

If you have any questions or comments, feel free to contact author of this article, Saurabh Nandu at


Back to Articles Page      

All information on this site is for training only. We do not warrant its correctness or its fitness to be used. The risk of using it remains entirely with the user. 


  Contact Us | E-mail Us | Site Guide | About PerfectXML | Advertise ©2004 All rights reserved. | Privacy