update xml to replace value
luanxiSep 21 2010 — edited Sep 22 2010I have seen good example on how to use updateXML to update the value as the one below,
but no luck on search on how to replace from one value to another.
Does anyone have example on how to replace value using updateXML?
Thanks,
Luan
insert into XML_CLOB values ( xmltype(
'<student id="211">
<personal idPer="2561">
<firstName>John</firstName>
<middleName>Michael</middleName>
<lastName>Scott</lastName>
<birthday>15-11-1984</birthday>
<address>8600 Beverly Blvd.</address>
<city>Los Angeles, CA.</city>
<country>USA</country>
</personal>
<personal idPer="2561">
<firstName>John</firstName>
<middleName>Michael</middleName>
<lastName>Scott</lastName>
<birthday>15-11-1984</birthday>
<address>8600 Beverly Blvd.</address>
<city>Los Angeles, CA.</city>
<country>USA</country>
</personal>
<personal idPer="2221">
<firstName>John</firstName>
<middleName>Michael</middleName>
<lastName>Scott</lastName>
<birthday>15-11-1984</birthday>
<address>8600 Beverly Blvd.</address>
<city>Los Angeles, CA.</city>
<country>USA</country>
</personal>
</student>'));
prompt 'select object_value from xml_clob';
select object_value from xml_clob;
prompt 'update XML_CLOBset object_value = updateXML( object_value,/student/personal/city/text(),New York City)where existsNode(object_value,/student[@id="211"]) = 1';
update XML_CLOB
set object_value = updateXML
(
object_value,
'/student/personal/city/text()',
'New York City'
)
where existsNode(object_value,'/student[@id="211"= 1;