且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 SQL Server 从复杂的 XML 结构中读取值

更新时间:2023-11-13 19:46:28

您的所有元素都定义了命名空间.您需要根据定义声明和指定它们

All your elements have namespaces defined. You need declare and specify them according to definitions

SELECT CAST([Table].[settings] as xml).value(
   'declare namespace top="http://dev.docuware.com/settings/workflow/processdef";
    declare namespace q2="http://dev.docuware.com/settings/workflow/processconfig";
    declare namespace nd="http://dev.docuware.com/settings/common";
    (/top:PrinterProcessDef/top:Configs/top:Config[@xsi:type="q2:RecognizeActConfig"]/q2:Body/q2:SampleDocument/nd:Data)[1]',  
        'varchar(max)')
FROM [DB].[dbo].[Table]