How to simple change node's attribute value of XMLTYPE in Oracle 11g r2?

oracle, plsql

Solution

You can use updatexml function:

declare
  fOrigXml XmlType := XmlType(
'<RootNode>
  <ChildNodes>
    <ChildNode Name="A"/>
    <ChildNode Name="B"/>
  </ChildNodes>
</RootNode>');
   fResXml XmlType;
begin
  select updatexml((fOrigXml), '/RootNode/ChildNodes/ChildNode[@Name="B"]/@Name', 'C') into fResXml from dual;
end;

Problem

I just wanna to change in this XML (contained in XMLTYPE variable) all nodes named "ChildNode" with "Name"="B" attribute values to "C": ``` <RootNode> <ChildNodes> <ChildNode Name="A"/> <ChildNode Name="B"/> </ChildNodes> </RootNode> DECLARE FXML XMLTYPE; BEGIN FXML := ...; -- see text before -- what next? END; ``` Thanks!

Original source