Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Creating nested elements in XML::Smart

by bitingduck (Chaplain)
on Dec 12, 2012 at 08:02 UTC ( #1008466=note: print w/replies, xml ) Need Help??


in reply to Creating nested elements in XML::Smart

This seems to work:

use strict; use warnings; use XML::Smart; my @pp=qw(Puebla01 Puebla02); my @shelf=qw(7480 7440); my @comment=("ATM Core switch","ATM access switch"); my $XML = XML::Smart->new() ; my $count=0; foreach (@pp){ $XML->{Shelf_Info}{switch}[$count]{Name} = "$_"; $XML->{Shelf_Info}{switch}[$count]{shelfType} = $shelf[$count]; $XML->{Shelf_Info}{switch}[$count]{shelfType}->set_node(1); $XML->{Shelf_Info}{switch}[$count]{commentText} = "$comment[$count +]"; $XML->{Shelf_Info}{switch}[$count]{commentText}->set_node(2); $count++; } $XML->save('test.xml') ;

It seems to want array refs to iterate over nodes.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1008466]
help
Chatterbox?
talexb admires the shimmering pool after an enjoyable hour-long All Hands meeting spent listening with one ear and reading Perlmonks with the other .. ear.
[talexb]: Used all my votes during that meeting .. been a while since I've done that. Now, back to work. Good localtime, monks!
[Corion]: talexb: You enjoyed the All Hands meeting in the pool?!
[Corion]: I understand "surfing" in the pool ;)
[talexb]: Corion I admired the pool .. I wasn't .. soaking in it. ;)

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2017-07-20 15:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (304 votes). Check out past polls.