SQL> with xml as (
2 select xmltype('<books>
3 <book>
4 <title genre="fiction">To kill a mocking bird</title>
5 <price>5.75</price>
6 <outofstockdate>2017-01-01</outofstockdate>
7 </book>
8 <book>
9 <title>Swallows and Amazons</title>
10 <price>6.99</price>
11 <outofstockdate/>
12 </book>
13 </books>') x from dual
14 )
15 select xt.column_value.getStringVal()
16 from xml, xmltable(
17 'for $i in /books/book return if (not(exists($i/title[@genre]))) then <books>{$i}</books> else ()'
18 passing x
19 ) xt;
XT.COLUMN_VALUE.GETSTRINGVAL()
---------------------------------------------------------------------------------------------------------------
<books><book><title>Swallows and Amazons</title><price>6.99</price><outofstockdate/></book></books>