Le Café Central de Deva
let.us.share.develop.more... Deva blogs!!
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?
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 http://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", "http://[servername]/[virtualdirectory]/[filename.xml]", False, "", ""
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;
5: public class Sample
7: public static void Main()
9: // Provide the respective values
10: HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://[ServerName]/[virtualdir]/[filename.xml]");
12: // Provide the Username and password.
13: request.Credentials = new NetworkCredential("[username]", "[password]");
15: // It downloads the XML file from the specified server.
16: HttpWebResponse response = (HttpWebResponse)request.GetResponse();
18: // Then it loads the XmlDocument.
19: XmlDocument doc = new XmlDocument();
23: // Finally don't forgot to release the resources of the response.