use strict; use warnings; use XML::LibXML; my $parser = XML::LibXML->new(); my $doc = $parser->load_xml(location => 'input.xml'); my %types = ( courbe => 'conifere', droite => 'resineux' ); for my $branch_node ($doc->findnodes('/arbre/branche')) { $branch_node->setAttribute(type => $types{$branch_node->getAttribu +te('name')}); } print $doc->toString;
In reply to Re: Add attribute to xml with XML::LibXML
by ikegami
in thread Add attribute to xml with XML::LibXML
by Yshyeeni
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |