Avatar of jetbet
jetbet
Flag for New Zealand asked on

perl XML::LibXML edit attribute

I am trying to open an XML file, change the value of a single attribute and then save it as another file. I want to use LibXml as this is a standard we use.
I have tried the following and many other combinations but cannot get it to work.

Can anyone help?
my $parser = XML::LibXML->new();
          my $tree = $parser->parse_file($file);
          my $root = $tree->getDocumentElement;
          my $meet_date = $root->getAttribute('meetingdate');
         

          my($node)  = $root->find('@meetingdate');
         $node->setData($meetingdate);

          print $tree->toString;


========== XML file stub ========
<?xml version="1.0" ?> 
- <meeting meetingdate="08 Sep 2010" meetingJetbetnumber="9" meetingType="GR"

Open in new window

Perl

Avatar of undefined
Last Comment
jetbet

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
jetbet

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy