SQL Server:XPATH 查询失败 [英] SQL Server: XPATH Query failing

查看:35
本文介绍了SQL Server:XPATH 查询失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 SQL Server Management Studio 中处理存储过程.有一列包含我试图使用 XPATH 访问的 XML 的列,但出现此错误:

I am working in SQL Server Management Studio on a stored procedure. There is a column containing XML that I am trying to access with XPATH but I get this error:

不允许使用内部子集 DTD 解析 XML.使用带有样式选项 2 的 CONVERT 来启用有限的内部子集 DTD 支持`

Parsing XML with internal subset DTDs not allowed. Use CONVERT with style option 2 to enable limited internal subset DTD support`

我阅读了有关转换和导入 xml 的文档,但没有成功.

I read the docs on convert and importing xml but no luck.

明确地说,我将 XML 存储在表的列中,现在想在存储过程中将其查询到内存中后使用 xpath 访问它.有人知道我该怎么做吗?

To be clear, I have XML stored in a column in a table, and now want to access it with xpath after querying it into memory in a stored procedure. Anyone know what I should do?

推荐答案

你最有可能得到这个是因为你在 XML 内部的某个地方使用了这样的文档定义:(MSDN 示例 的 DTD)

Your most likely getting this because somewhere inside of your XML you are using a document definition such as this: (MSDN example of DTD)

<!DOCTYPE DOC [<!ATTLIST elem1 attr1 CDATA "defVal1">]><elem1>January</elem1>

默认情况下,Microsoft 会阻止此操作,因为它会造成潜在的安全漏洞.带有样式选项 2 的转换消息告诉您,您可以启用对 DTD 的部分支持,以便通过使用 CONVERT 函数,因为它与 XML 相关.

Microsoft blocks this by default as it creates a potential security hole. The convert with style option 2 message is telling you that you can enable partial support for DTD in order to process this XML through use of the CONVERT function as it relates to XML.

我没有这样做的个人经验,所以我只能提供指向 MSDN 的链接.

I don't have personal experience with doing that so I can't offer more than the link to MSDN.

唯一的其他选项是在 Microsoft 不推荐的服务器上启用完整的 DTD 支持.

The only other option is to enable full DTD support on the server which Microsoft does not recommend.

这篇关于SQL Server:XPATH 查询失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆