Saya memiliki cuplikan contoh Xml berikut yang diambil dari file yang lebih besar:
<EntityAttributeValue>
<Value />
<Attribute>
<Id>0</Id>
<Name>Use 3</Name>
<AttributeType>other</AttributeType>
</Attribute>
<AttributeValueId>999998</AttributeValueId>
<ProductTypeId xsi:nil="true" />
</EntityAttributeValue>
Saya mencoba menghapus node <ProductTypeId>
menggunakan SQL sehingga tampilan di atas akan seperti ini:
<EntityAttributeValue>
<Value />
<Attribute>
<Id>13</Id>
<Name>Use 3</Name>
<AttributeType>other</AttributeType>
</Attribute>
<AttributeValueId>999998</AttributeValueId>
</EntityAttributeValue>
Saya telah menggunakan yang berikut ini untuk menanyakan SQL XML dan mengisolasi cuplikan di atas (yang pertama)
select t.c.query('.') as Attributes
from @XMLData.nodes('/Item/ContentAttributeValues/EntityAttributeValue') t(c)
where t.c.value('(Attribute/Id)[1]','INT') = 0
saya telah mencoba
SET @XMLData.modify('delete (/Item/ContentAttributeValues/EntityAttributeValue/ProductTypeId)')
untuk menghapus semua id produk, tetapi tidak berhasil, bantuan apa pun akan sangat diterima.
Bersulang
xml.modify(
tampaknya benar. - person David Browne - Microsoft   schedule 17.02.2020