Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: XML::Simple find and add

by reasonablekeith (Deacon)
on Dec 05, 2007 at 10:59 UTC ( #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? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2022-08-08 06:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?