开发者

What does XMLdocument.load(url) Internal does to Load the XML from other Location

I want to know what call xmldocument internally uses to load the XML, does 开发者_开发技巧it make httpwebsrequest or anything else.

I read about it here, but there is no enough info about the internals

http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.load.aspx

 XmlDocument doc = new XmlDocument();

 doc.Load("http://someotherserver/test.xml");   

Can anyone please tell me about this.


I think this is the code that does it.

It's in the XmlDownloadManager class which is internal

private Stream GetNonFileStream(Uri uri, ICredentials credentials)
{
    WebRequest request = WebRequest.Create(uri);
    if (credentials != null)
    {
        request.Credentials = credentials;
    }
    WebResponse response = request.GetResponse();
    HttpWebRequest request2 = request as HttpWebRequest;
    if (request2 != null)
    {
        lock (this)
        {
            if (this.connections == null)
            {
                this.connections = new Hashtable();
            }
            OpenedHost host = (OpenedHost) this.connections[request2.Address.Host];
            if (host == null)
            {
                host = new OpenedHost();
            }
            if (host.nonCachedConnectionsCount < (request2.ServicePoint.ConnectionLimit - 1))
            {
                if (host.nonCachedConnectionsCount == 0)
                {
                    this.connections.Add(request2.Address.Host, host);
                }
                host.nonCachedConnectionsCount++;
                return new XmlRegisteredNonCachedStream(response.GetResponseStream(), this, request2.Address.Host);
            }
            return new XmlCachedStream(response.ResponseUri, response.GetResponseStream());
        }
    }
    return response.GetResponseStream();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜