Oracle DB: Delete or Replace XML

Here are 2 examples of how to delete or replace xml part:    

Supposing that we have a variable l_xmltype of type XMLTYPE containing an XML:  

--delete XML;
select xmltype(deletexml(xmltype('<s:a xmlns:s="qw"><s:b><return></return></s:b></s:a>'),
'/s:a/s:b/return', 'xmlns:s="qw"').getclobval()) the_result from dual;

--replace XML:
select xmltype(updatexml(xmltype('<s:a xmlns:s="qw"><s:b><return></return></s:b></s:a>'),
'/s:a/s:b/return/text()', '11527', 'xmlns:s="qw"').getclobval()) the_result from dual;

Leave a Reply