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');

          print $tree->toString;

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

Open in new window

Who is Participating?
jetbetConnect With a Mentor Author Commented:
I have found the answer myself. Please close this question
foreach my $file (@input_files)
        $input_file = basename($file);
        if ($input_file =~ /(Ver4_)(\d{4}_\d{2}_\d{2})(.*)/)
          $prefix = $1;
          $filedate = $2;
          $suffix = $3;
          my $today = strftime("%Y_%m_%d", localtime);
          $newfilename = $1.$today.$3;
          print ("from $input_file to $newfilename \n");

          $meetingdate = strftime("%d %b %Y", localtime);

          my $parser = XML::LibXML->new();
          my $tree = $parser->parse_file($file);
          my $root = $tree->getDocumentElement;

          $root->setAttribute( 'meetingdate', $meetingdate );



Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.