【发布时间】:2023-03-06 21:38:01
【问题描述】:
我有一个 SQL Server 数据库,其中包含一个包含 XML 列的表。我想从中提取数据,但我们在名称上使用了前缀。
这是一个例子:
<cfdi:comprobante xmlns:cfdi="" total="" tax="">
<cfdi:sender information="" moreinformation=""/>
<cfdi:receiver information="" moreinformation=""/>
<cfdi:addments>
<another:payment information="" moreinformation="">
<another:Movements date="" description="hello" amount="100.00" contract="10"/>
<another:Movements date="" description="hello2" amount="200.00" contract="20"/>
<another:Movements date="" description="bye" amount="300.00" contract="30"/>
<another:Movements date="" description="bye2" amount="400.00" contract="40"/>
</another:payment>
</cfdi:addments>
</cfdi:comprobante>
我需要的是一个查询,它可以提取如下所示的运动:
| ID(other column | Contract | amount | Description |
|---|---|---|---|
| 39098 | 10 | 100.00 | hello |
| 39098 | 20 | 200.00 | hello2 |
| 39098 | 30 | 300.00 | bye |
| 39098 | 40 | 400.00 | bye2 |
我希望我已经足够清楚了。请在这方面真的需要帮助。
提前谢谢你。
【问题讨论】:
-
XML 元素上的那些“前缀”是 XML 命名空间 - 但是为了呈现查询以执行您想要的操作,我们需要查看这些 XML 命名空间的位置已定义(如
xmlns:cfdi- 其他可能在 XML 数据中较早的位置) -
嗨!谢谢你的回复,我真的没有权限检查我有这样的人: xmlns:cfdi="sat.gob.mx/cfd/3" xmlns:xsi="w3.org/2001/XMLSchema-instance" xmlns:another="pegasotecnologia.com/secfd/Schemas"
标签: sql-server xml