简体   繁体   English

xdocument.load(URL)或(流)

[英]xdocument.load (url) or (stream)

I am confused about xdocument.load. 我对xdocument.load感到困惑。

I did a search and found MSDN XDOCUMENT.LOAD 我进行了搜索,发现MSDN XDOCUMENT.LOAD

It does not state that you can supply a URL as a load option, but you can and it does work by the many examples I found. 它没有声明您可以提供URL作为加载选项,但是可以,并且确实可以通过我发现的许多示例来使用。

So, is this documented anywhere? 那么,此文件记录在任何地方吗? Is it better to use WebResponse to get a stream? 使用WebResponse获得流是否更好?

I am confused, please help. 我很困惑,请帮忙。

See MSDN : 参见MSDN

The XmlUrlResolver class is the default resolver for all classes in the System.Xml namespace. XmlUrlResolver类是System.Xml命名空间中所有类的默认解析器。 It supports the file:// and http:// protocols and requests from the WebRequest class. 它支持file://和http://协议以及WebRequest类的请求。 In many cases, if you do not specify an XmlResolver object that your application should use, an XmlUrlResolver object with no user credentials is used to access XML resources. 在许多情况下,如果未指定应用程序应使用的XmlResolver对象,则将使用没有用户凭据的XmlUrlResolver对象来访问XML资源。

So behind the simple APIs taking a string with a URI an XmlUrlResolver is used. 因此,在简单的API使用带URI的字符串的背后,使用了XmlUrlResolver。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM