Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

replace multiple occurrences of a node in XML

3778846Sep 7 2018 — edited Sep 10 2018

Hi

I'm trying to delete and replace the value of various nodes within XML, where the nodes I'm changing can occur more than once in my document

DECLARE
  v_xml      xmltype;
  w_xml      xmltype;
 
BEGIN
    --Generate simple XML document to pretend we received it by some interface
    v_xml := xmltype.createxml('
    <Response>
        <Card>
              <Address attr_cust="1">
                <Line1>abc</Line1>
                <Line2>def</Line2>
                <Line3>ghi</Line3>
                <Line4>jkl</Line4>
                <Line5>mno</Line5>
                <PostCode>123</PostCode>
                <Country/>
              </Address>
              <Email>aaa.bbb@ccc.ddd</Email>
        </Card>
        <Card>
              <Address attr_cust="1">
                <Line1>abc</Line1>
                <Line2>def</Line2>
                <Line3>ghi</Line3>
                <Line4>jkl</Line4>
                <Line5>mno</Line5>
                <PostCode>123</PostCode>
                <Country/>
              </Address>
              <Email>aaa.bbb@ccc.ddd</Email>
        </Card>
    </Response>
    ');

    select
      XMLQuery('copy $tmp := . modify
                (delete nodes
                    ($tmp//Line1
                    ,$tmp//PostCode
                    ,$tmp//Email
                    ),
                replace value of node $tmp//Line3 with "x",
                replace value of node $tmp//@attr_cust with "0"
                ) return $tmp'
               PASSING v_xml RETURNING CONTENT)
        INTO w_xml
        FROM (SELECT v_xml FROM dual);

    dbms_output.put_line( w_xml.extract('/*').getClobVal() );
END;

it almost works ok, except that it errors for example if node Line3 or attribute attr_cust occur more than once in my XML document

[1]: XVM-01136: [XUTY0008] Invalid target expression for 'replace'

is there a way round this?

Thanks

This post has been answered by cormaco on Sep 10 2018
Jump to Answer

Comments

There is no installer, just a zip.

You could build your own msi package though.

RedWhiteNBlue

Okay, if there is no installation then that explains why there are no shortcuts to launch the application.

In retrospect, it did seem like the application was up and running rather quickly. So, I just assumed that it had been installed. Thank You for your response.

1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 8 2018
Added on Sep 7 2018
1 comment
2,506 views