首页 > 解决方案 > 使用包含命名空间的 SQL-SERVER-2016 从 XML 中检索数据

问题描述

在此之前,在 AppHdr 和 Document 中收到没有命名空间的 XML,我能够从中检索数据。

我在新引入 XML 之前的查询:

SELECT XMLData.Value('(/Root/AppHdr/BizMsgIdr)[1]', 'CHAR(16)') As MessageID,
       XMLData.Value('(/Root/Document/CorpActnGnlInf/OffclCorpActnEvtId)[1]', 'CHAR(16)') As EventID
FROM Announcement

新收到的 XML 如下:

<Root>
  <AppHdr xmlns="urn:iso:std:iso:20022:tech:xsd:head.001.001.01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <BizMsgIdr>MY190531X0000007</BizMsgIdr>
  </AppHdr>
  <Document xmlns="urn:iso:std:iso:20022:tech:xsd:seev.031.001.08" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <CorpActnGnlInf>
      <OffclCorpActnEvtId>MY190531BONU0007</OffclCorpActnEvtId>
    </CorpActnGnlInf>
  </Document>
</Root>

请协助介绍新的 XML 查询如何引入。

标签: xmlsql-server-2016

解决方案



推荐阅读