Greetings, Requirement goes like this. I have perl script reading from a MQ Series queue. This queue has messages in form of XML.For example- 1 message is like -

<CLIENT_INFO> <LOCATION> New York </LOCATION> <FIELD> FINANCE GROUP </FIELD> <NO_OF_WORKERS> 123 </NO_OF_WORKERS> </CLIENT_INFO>

My perl script reads messgaes from this queue, and drops them to another queue after creating a backup in a text file. My requirement is I have check the value of a particular tag for example, value of <FIELD>, if that is say "FINANCE GROUP", I have to change it to "FINANCIAL SYSTEMS" and then drop to the other queue. I tried below, but for some reason it did not work. COuld you please help. Pl note I would prefer doing below way or other wise I have XML Parser installed. Sample of my script -
# Connect to qmgr $qmgr = MQSeries::QueueManager->new ( QueueManager => $hOpts{m}, AutoC +onnect => 0) or die "Unable to instantiate MQSeries::QueueManager object\n" +; $qmgr->Connect() or die("Unable to connect to queue manager\n" . "Com +pCode => " . $qmgr->CompCode() . "\n" . "Reason => " . $qmgr->Reason() . " (", MQReasonToText($qmgr->Reason()) . ")\n"); # open input and output queues my $qIn =MQSeries::Queue->new(QueueManager => $qmgr, Queue => $hOpts{i +}, Options=>MQSeries::MQOO_INPUT_SHARED ) or die "Unable to open queue $hOpts{i}" ; my $qOut=MQSeries::Queue->new ( QueueManager => $qmgr, Queue => $hOpts +{o}, Options=>MQSeries::MQOO_OUTPUT | MQSeries::MQPMO_S ET_ALL_CONTEXT ) or die "Unable to open queue $hOpts{o}" ; until( $time_to_die ) { my $message = MQSeries::Message->new(MsgDesc=>{Persistence=>1} +); # Get message from queue $result = $qIn->Get( Message => $message, Sync=>1, Wait=>-1 ); + my $msgDescRef = $message->MsgDesc; my $data = $message->Data; my $field_name = GetXMLValue($data, "FIELD"); if ($field_name eq 'FINANCE GROUP') { $field_name = 'FINANCIAL SYSTEMS'; $msgDescRef->{"FIELD"} = $field_name ; } for(1..$num_retries) { $result = $qOut->Put( Message => $message, Sync => 1, PutMsgOpts =>{ Options=>MQSeries::MQPM +O_SET_ALL_CONTEXT || + MQSeries::MQPMO_FAIL_IF_QUIESCING}); if ($result > 0) { last; } sleep $time_to_wait; }

In reply to Changing XML Tag value in Perl Script by Rajpreet1985

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.