Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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;


Comment on Re: Add attribute to xml with XML::LibXML
Download Code

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 scrutinizing the Monastery: (17)
As of 2014-12-18 16:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (58 votes), past polls