Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: XML::Simple find and add

by reasonablekeith (Deacon)
on Dec 05, 2007 at 10:59 UTC ( [id://655067]=note: print w/replies, xml ) Need Help??


in reply to XML::Simple find and add

KeyAttr should be 'id', (which is set by default anyway), you also need to set on ForceArray (a single 'tc' element would parse differently otherwise, have a look in the docs.)

The total code is then as simple as...

my $xml_string = qq| <exec> <tc id="001.001" version=""/> </exec>|; my $xml_simple = XMLin( $xml_string, 'ForceArray' => 1); $xml_simple->{'tc'}->{'001.001'}->{'version'} = "new value"; print XMLout($xml_simple);
---
my name's not Keith, and I'm not reasonable.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-25 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found