小编dra*_*fly的帖子

SQL Server 子节点中的空白 xml 命名空间

您好,我需要 sql 中以下内容的帮助:

我需要创建一个这种格式的xml文件

<Document xmlns="urn:iso:std:iso:20022:tech:xsd:001.002.001.04">
 <FIToFIPmtStsRpt>
  <GrpHdr>
    <MsgId></MsgId>
  </GrpHdr>
  <OrgnlGrpInfAndSts>
    <OrgnlMsgId />
  </OrgnlGrpInfAndSts>
 </FIToFIPmtStsRpt>
</document>
Run Code Online (Sandbox Code Playgroud)

目前我有一个保存主要信息的变量,并且我建立了信息之间的关系(假设 grphdr 可以使用不同的信息多次插入到主 xml 中)

declare @xml xml='<Document
xmlns="urn:iso:std:iso:20022:tech:xsd:001.002.001.04">
<FIToFIPmtStsRpt>
</FIToFIPmtStsRpt>
</Document>
'

declare @xmlgrp xml='<GrpHdr>
  <MsgId></MsgId>
</GrpHdr>'
--here i do some code to fill msgid
Run Code Online (Sandbox Code Playgroud)

然后当我将 grphdr 添加回主 xml 时

SET @xml.modify
('declare namespace a= "urn:iso:std:iso:20022:tech:xsd:001.002.001.04";
insert sql:variable("@xmlgrp") 
into (a:Document/a:FIToFIPmtStsRpt)[1]')

select @xml
Run Code Online (Sandbox Code Playgroud)

我需要找出顶级文件格式,但现在发生的情况如下

<Document xmlns="urn:iso:std:iso:20022:tech:xsd:001.002.001.04">
 <FIToFIPmtStsRpt>
   <GrpHdr xmlns="">-- i need this xmlns tag out
     <MsgId />
   </GrpHdr>
 </FIToFIPmtStsRpt>
 </Document>
Run Code Online (Sandbox Code Playgroud)

不知怎的,我需要 xml 中的空 xmlns …

xml sql t-sql sql-server xml-namespaces

2
推荐指数
1
解决办法
1941
查看次数

标签 统计

sql ×1

sql-server ×1

t-sql ×1

xml ×1

xml-namespaces ×1