Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Remove Parent Node if child node contains in xml

$
0
0

Hi All,

I have this data.

declare @xml xml 
set @xml ='<tr><td>12345</td><td>2343</td><td>abcede</td></tr><tr><td>delete</td><td>ffhfhf</td><td>hfhfh</td></tr>'
select @xml

Now my task is, if any one of the <tr> contains 'delete' text in any <td> i have to delete that<tr>.

i have written this 

set  @xml.modify('delete //tr/td[text()[contains(.,"delete")]]') 

but its not removing entire <tr>. what should i apply to get the below result.

<tr><td>12345</td><td>2343</td><td>abcede</td></tr>

Thanks in advance.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>