Sql server 过滤子元素,但使用XPath保留原始结构
我如何从中获得:Sql server 过滤子元素,但使用XPath保留原始结构,sql-server,xml,xpath,filter,xquery,Sql Server,Xml,Xpath,Filter,Xquery,我如何从中获得: <a id="1"> <b> <c type="1"/> <c type="0"/> <c type="0"/> </b> <b> <c type="1"/> <c type="0"/> <c type="1"/> </b>
<a id="1">
<b>
<c type="1"/>
<c type="0"/>
<c type="0"/>
</b>
<b>
<c type="1"/>
<c type="0"/>
<c type="1"/>
</b>
</a>
<a id="2">
<b>
<c type="1"/>
<c type="1"/>
<c type="0"/>
</b>
<b>
<c type="1"/>
<c type="1"/>
</b>
</a>
以下是:
<a id="1">
<b>
<c type="1"/>
</b>
<b>
<c type="1"/>
<c type="1"/>
</b>
</a>
<a id="2">
<b>
<c type="1"/>
<c type="1"/>
</b>
<b>
<c type="1"/>
<c type="1"/>
</b>
</a>
所以我想过滤元素,但保留原始结构。我使用sql server。
我尝试了一些变化,但没有一个像我预期的那样工作。其中@x是您的xml
set @x.modify('delete (/a/b/c[@type="0"])')
到底是什么问题?你尝试了什么?你被困在哪里?