in reply to Re: Modifying XML with LibXML
in thread Modifying XML with LibXML

Playing around with XML::LibXML::Attribute objects is usually unnecessary. It's easier to select the element and then use getAttribute and setAttribute, or if you have a vaguely recent copy of XML::LibXML, just treat the element as a hashref...

use strict; use warnings; use XML::LibXML 2; my $xml = 'XML::LibXML'->load_xml(IO => \*DATA); $_->{value}++ for $xml->findnodes('//key[@name="Repetitions"]'); print $xml->toString; __DATA__ <root> <parameters> <key name="Repetitions" value="500" /> <key name="Mode" value="COLD" /> ... </parameters> </root>
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name