<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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |