Anyone used XML::Smart ?

Edwardson, Tony Tony.Edwardson at commerzbank.com
Tue Dec 11 04:13:59 PST 2007


We use a batch scheduler called UC4 with which you can export and import the
config as XML and I am trying to write a tool to be able to make changes to
the jobs by changing the exported XML before re-importing it.

XML::Simple doesn't cut the mustard for this so I am trying to use
XML::Smart.

Here's a (simplified) sample of the exported XML

 

<?xml version="1.0" encoding="utf-8" ?>

<uc-export>

  <JOBS_UNIX name="JOB1">

    <SCRIPT>

        <MSCRI>JOB1 BEFORE CHANGE</MSCRI>

    </SCRIPT>

  </JOBS_UNIX>

<JOBS_UNIX name="JOB2">

    <SCRIPT>

        <MSCRI>JOB 2 BEFORE CHANGE</MSCRI>

    </SCRIPT>

  </JOBS_UNIX>

</uc-export>

 

 

The bit I want to change is the <MSCRI> bit which contains the code that
gets run

What I can't workout is the syntax to use with XML::Smart to be able to
change the MSCRI values

 

Here's my script :-

#!/usr/bin/perl

use strict;

use warnings;

use XML::Smart;

my $xml = < XML as per sample above >

my $obj = new XML::Smart($xml) or die "Can't understand $xml: $!\n";

 

Do something like this :-

    $obj->{'uc-export'}{JOBS_UNIX}{JOB1}{SCRIPT}{MSCRI}->content("CHANGED TO
THIS");

 

$content =  $XML->{root}->data();

print $content;

 

I've tried loads of different syntaxes but so far everything I've tried has
created new entries in the XML rather than change the existing values.

 

Anyone any ideas ?

 

Cheers

Tony

 

-- 

 



********************************************************************** 
This is a commercial communication from Commerzbank AG.

This communication is confidential and is intended only for the person to
whom it is addressed.  If you are not that person you are not permitted to
make use of the information and you are requested to notify
<mailto:LONIB.Postmaster at commerzbankib.com> immediately that you have
received it and then destroy the copy in your possession.

Commerzbank AG may monitor outgoing and incoming e-mails. By replying to
this e-mail you consent to such monitoring. This e-mail message and any
attached files have been scanned for the presence of computer viruses.
However, you are advised that you open attachments at your own risk.

This email was sent either by Commerzbank AG, London Branch, or by
Commerzbank Corporates & Markets, a division of Commerzbank. Commerzbank AG
is a limited liability company incorporated in the Federal Republic of
Germany. Registered Company Number in England BR001025. Our registered
address in the UK is 60 Gracechurch Street, London, EC3V 0HR. We are
regulated by the Financial Services Authority for the conduct of investment
business in the UK and we appear on the FSA register under number 124920. 

**********************************************************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/miltonkeynes-pm/attachments/20071211/01a7c0be/attachment.html 


More information about the MiltonKeynes-pm mailing list