用 SQL 服务器中的新元素替换 XML 元素
将此内容的 元素替换为多行中具有
XML
类型的列的新元素:
Replace <apipAccessbility>
element of this content with a new element in multiple rows with a column of type XML
:
<Item title="1234" xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2">
<ItemBody>xyz</ItemBody>
<apipAccessibility xmlns="http://www.imsglobal.org/xsd/apip/apipv1p0/imsapip_qtiv1p0">
<accessibilityInfo>
Blablah
</accessibilityInfo>
</apipAccessibility>
</Item>
一旦元素被更新,它应该是这样的:
Once element is updated it should look like this:
<Item title="1234" xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2">
<ItemBody>xyz</ItemBody>
<apipAccessibility xmlns="http://www.imsglobal.org/xsd/apip/apipv1p0/imsapip_qtiv1p0"/>
</Item>
推荐答案
您可以使用 修改
和删除
:
You could use modify
and delete
:
UPDATE tab
SET col.modify('
declare namespace NS="http://www.imsglobal.org/xsd/imsqti_v2p2";
declare namespace NS2="http://www.imsglobal.org/xsd/apip/apipv1p0/imsapip_qtiv1p0";
delete /NS:Item/NS2:apipAccessibility/*')
-- WHERE id = 1;
LiveDemo
输出:
<Item xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" title="1234">
<ItemBody>xyz</ItemBody>
<apipAccessibility xmlns="http://www.imsglobal.org/xsd/apip/apipv1p0/imsapip_qtiv1p0" />
</Item>
相关文章