Link to home
Start Free TrialLog in
Avatar of jetbet
jetbetFlag 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

ASKER CERTIFIED SOLUTION
Avatar of jetbet
jetbet
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial