Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: XML::Simple add

by strat (Canon)
on Nov 27, 2007 at 07:53 UTC ( #653167=note: print w/replies, xml ) Need Help??


in reply to XML::Simple add

I would use XML::DOM for it, e.g.

use XML::DOM; my $file = 'file.xml'; my $xmlParser = XML::DOM::Parser->new; my $xmlDocument = $xmlParser->parsefile( $file ) or die ....; # get parent node my $nodes = $xmlDocument->getElementsByTagName( 'exec' ); my $parentNode = $nodes->item( 0 ) or die "No node with id 0 available\n"; my $newChild = $xmlDocument->createElement('tc'); $newChild->setAttribute( id => '12346' ); $parentNode->appendChild( $newChild ); print $xmlDocument->toString; # debug $xmlDocument->printToFile( $outputfilename) or die ...; $xmlDocument->dispose;

(Not tested)

Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2016-10-01 19:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (6 votes). Check out past polls.