Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Add attribute to xml with XML::LibXML

by ikegami (Pope)
on Jul 31, 2013 at 01:35 UTC ( #1047152=note: print w/replies, xml ) Need Help??


in reply to Add attribute to xml with XML::LibXML

Or using XPaths:
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;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1047152]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2016-09-27 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (507 votes). Check out past polls.