我試圖解析一段XML並刪除包含某些值的節點。我知道如何刪除它們,如果值是確切的,但我想使用像「包含」的東西。使用TSQL從XML中刪除具有特定值的節點
本工程以刪除準確:
update @XML set data.modify('delete //Message[text() = "customer has deleted their account"]')
但我想刪除其中的「消息」節點只包含文本,像:
update @XML set data.modify('delete //Message[contains(text(), "customer")]')
然而,這將返回錯誤:
XQuery [@XML.data.modify()]: 'contains()' requires a singleton (or empty sequence), found operand of type 'xdt:untypedAtomic *'
級長。我得到了非常相似的東西,但是這只是兩步。刪除節點的內容,然後刪除空節點。這更優雅。 – 2013-02-25 18:34:26