MSXML 6、用户/密码身份验证、ResolveExternals
据我所知,如果必须从用户/密码保护的 URL 加载并解析 XML 资源,则不能仅使用 MSXML DOM.Load()。没有地方可以指定凭据。
然而,如果您使用 XMLHTTPRequest 获取资源并将其解析为 DOM(通过其 .responseXML 属性),您将无法为 .resolveExternals 属性指定值。
当您使用 MSXML 3、4(甚至 5)时,这或多或少会起作用,其中默认为 True,但在 MSXML 6 中,它默认为 False:
在 MSXML 3.0、MSXML 4.0 和 MSXML 5.0 中,默认的 resolveExternals 值为 True。在 MSXML 6.0 中,默认设置为 False。
如果此属性设置为 False,则没有外部包含和导入 将会得到解决。
有没有我没有看到的解决方法?通常我需要解决外部问题,尤其是在处理 XSD 或 WSDL 时。
或者我是在欺骗自己,也许 .resolveExternals 在使用 XMLHTTPRequest 时永远不会应用(仅 DOM.Load() 调用)?
If one must load and parse an XML resource from a user/PW-protected URL you cannot just use an MSXML DOM.Load() as far as I can tell. There is no place to specify the credentials.
Yet if you use XMLHTTPRequest to obtain and parse the resource into a DOM (via its .responseXML property) you have nowhere to specify a value for the .resolveExternals property.
This more or less works out when you use MSXML 3, 4, (or even 5) where it defaults to True, however in MSXML 6 it defaults to False:
In MSXML 3.0, MSXML 4.0, and MSXML 5.0 the default resolveExternals
value is True. In MSXML 6.0, the default setting is False.If this property is set to False, no external includes and imports
will be resolved.
Is there a way around this that I am not seeing? Normally I need the externals resolved, especially when dealing with XSDs or WSDLs.
Or am I fooling myself, and perhaps .resolveExternals never applies when using XMLHTTPRequest (only DOM.Load() calls)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你尝试过这样的事情吗?
唯一的问题是该解决方案可能仅适用于 MSXML XMLHTTP ActiveX 对象。
编辑:这是一个使用 IE9 的具体示例:
sample.xml
sample.dtd
如果您使用 IE9 运行上述 cod,您将成功解析实体。但是,如果切换到注释掉的XMLHttpRequest,就会失败。
PS:我以为你在谈论 IE 内部的脚本,并且有一个名为 XMLHttpRequest 的 Trident 本机组件,它与 XmlHttp ActiveX 组件有很大不同。但是,如果您引用驻留在 MSXML6.DLL 中的 IXMLHttpRequest COM 接口,则可以轻松地将上述代码转换为 C++。
Have you tried something like this?
The only thing is the solution may only work with MSXML XMLHTTP ActiveX object.
Edit: here is a concrete sample with IE9:
sample.xml
sample.dtd
If you run the above cod with IE9, you'll successfully get the entity resolved. However, if you switch to the commented out XMLHttpRequest, you will fail.
PS: I thought you were talking about scripting inside IE, and there is a Trident native component called XMLHttpRequest which is quite different from XmlHttp ActiveX component. However, if you are referring to IXMLHttpRequest COM interface residing in MSXML6.DLL, you can translate the above code into C++ with ease.