我正在尝试粉碎以下 XML,但我无法使用 OPENXML 构造获得任何结果,但我的输出看起来不正确。关于如何重写这个有什么建议吗?
<?xml version="1.0" encoding="UTF-8"?> <results
xmlns="https://crr.clm.ibmcloud.com/rs/query/1111/dataservice/ns"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="https://crr.clm.ibmcloud.com/rs/query/1111/dataservice/ns
https://crr.clm.ibmcloud.com/rs/query/1111/dataservice/xsd">
<result>
<a>a1</a>
<b>2</b>
<c>a1332</c>
<d>text.</d>
<e>Risk 2</e>
<f> </f>
<g>a123</g>
<h>1223324aaa</h>
<i>l1245</i>
<j>Complete</j>
<k>Not yet reported</k> </result>
请注意以下是我正在使用的代码片段
DECLARE @xml XML;
DECLARE @idoc INT;
SELECT @xml = CONVERT(XML, cast(results AS VARCHAR(MAX)), 2) FROM stg.requirements;
EXEC sys.sp_xml_preparedocument @idoc OUTPUT
,@xml
,'<results xmlns="https://crr.clm.ibmcloud.com/rs/query/1111/dataservice/ns" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="https://crr.clm.ibmcloud.com/rs/query/1111/dataservice/ns https://crr.clm.ibmcloud.com/rs/query/1111/dataservice/xsd"/>';
SELECT *
FROM
OPENXML(@idoc, '/*', 1)
WITH ()
EXEC sys.sp_xml_removedocument @idoc;
--SELECT * FROM #temp
DROP TABLE IF EXISTS #temp