我从一个较大的文件中获取了以下 Xml 示例片段:
<EntityAttributeValue>
<Value />
<Attribute>
<Id>0</Id>
<Name>Use 3</Name>
<AttributeType>other</AttributeType>
</Attribute>
<AttributeValueId>999998</AttributeValueId>
<ProductTypeId xsi:nil="true" />
</EntityAttributeValue>
我正在尝试<ProductTypeId>
使用 SQL 删除节点,以便上面的内容如下所示:
<EntityAttributeValue>
<Value />
<Attribute>
<Id>13</Id>
<Name>Use 3</Name>
<AttributeType>other</AttributeType>
</Attribute>
<AttributeValueId>999998</AttributeValueId>
</EntityAttributeValue>
我使用以下 SQL 查询 XML 并隔离上面的代码片段(第一个)
select t.c.query('.') as Attributes
from @XMLData.nodes('/Item/ContentAttributeValues/EntityAttributeValue') t(c)
where t.c.value('(Attribute/Id)[1]','INT') = 0
我试过了
SET @XMLData.modify('delete (/Item/ContentAttributeValues/EntityAttributeValue/ProductTypeId)')
删除所有产品ID,但无济于事,任何帮助都会得到很大的帮助。
干杯