Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Creating nested elements in XML::Smart

by choroba (Abbot)
on Dec 14, 2012 at 07:01 UTC ( #1008784=note: print w/ replies, xml ) Need Help??


in reply to Creating nested elements in XML::Smart

A solution using XML::XSH2, a wrapper around XML::LibXML.

#!/usr/bin/perl use warnings; use strict; use XML::XSH2; package XML::XSH2::Map; use constant { TYPE => 0, COMMENT => 1, }; our %Shelves = ( Puebla01 => [7480, 'ATM Core switch'], Puebla02 => [7440, 'ATM access switch'], ); package main; xsh << '__XSH__'; create Shelf_Info ; for my $shelf in { sort keys %Shelves } { my $switch := insert element switch append /Shelf_Info ; cd $switch ; set @Name $shelf ; set shelfType { $Shelves{$shelf}[TYPE] } ; set commentText { $Shelves{$shelf}[COMMENT] } ; } save :f 'test.xml' ; __XSH__
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: Creating nested elements in XML::Smart
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2014-12-25 19:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (162 votes), past polls