Nutshell : MSXML is not supported in .Net applications

I started working from Visual Basic 6, where i had used XML Parser (MS XML) to fetch the data's using WebDAV. But the same logic won't apply for you when you do with .Net applications.

So, where we need to use MSXML and .Net Framework classes's for XML?

  • Microsoft XML Core Services (MSXML) : As i updated you earlier you can easily use MSXML in Visual Studio 6.0 applications as DOM and SAX Parser with support for XSLT and XPath.
  • .NET Framework Classes for XML : But when you're planning to implement the XML, then you need to make use of System.XML, the .Net framework classes for XML instead of MSXML.
    • Because the System.Xml namespace provides standards-based support for processing XML.
    • System.xml is not just the managed version of MSXML;
    • its functionality may overlap that of the MSXML COM library, and it also contains a rich object model and hierarchy.

FYI: You can go through this below given article, which gives overall view and design goals of XML in the .Net Framework.

Design Goals for XML in the .NET Framework
https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondesigngoalsforxmlframeworkinnet.asp

No Official support. Do you know why it so?

Officially Microsoft does not support the use of MSXML (Microsoft’s COM-based XML parser) in .NET applications.

This is because MSXML uses threading models and garbage-collection mechanisms that are not compatible with the .NET Framework. Using MSXML in .NET applications through COM interoperability can result in unexpected problems that are difficult to debug.

Please note that Microsoft does not recommend or support directly instantiating and using MSXML objects in .NET code, nor does Microsoft recommend or support marshalling MSXML interface pointers across the interop boundary

So what is the workaround or best practice needs to be done?

Support for implementing standards-based XML functionality in .NET applications is built into the .NET Framework. The .NET Framework classes in the System.xml namespaces should be used to implement standards-based XML functionality in .NET applications.

Code snippets: FYI: I have enclosed couple of code snippets for your reference.

Earlier we might have created a web request to a web server like this using MSXML,

    1:  Dim oXMLHttpRequest As New MSXML2.XMLHTTP
    2:  ' Provide the respective values
    3:  oXMLHttpRequest.open "GET", "https://[servername]/[virtualdirectory]/[filename.xml]", False, "", ""
    4:  oXMLHttpRequest.send
    5:  Debug.Print (oXMLHttpRequest.responseText)

When you create the .Net applications, you need to do the same by using .Net framework classes like,

    1:      using System;
    2:      using System.Xml;
    3:      using System.Net;
    4:      
    5:      public class Sample    
    6:      {
    7:          public static void Main()        
    8:          {
    9:              // Provide the respective values
   10:              HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://[ServerName]/[virtualdir]/[filename.xml]");
   11:   
   12:              // Provide the Username and password.
   13:              request.Credentials = new NetworkCredential("[username]", "[password]");
   14:   
   15:              // It downloads the XML file from the specified server.
   16:              HttpWebResponse response = (HttpWebResponse)request.GetResponse();
   17:              
   18:              // Then it loads the XmlDocument.
   19:              XmlDocument doc = new XmlDocument();            
   20:              doc.Load(response.GetResponseStream());
   21:              doc.Save(Console.Out);
   22:   
   23:              // Finally don't forgot to release the resources of the response.
   24:              response.Close();
   25:          }
   26:      }