Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Creating nested elements in XML::Smart

by choroba (Canon)
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 drinking their drinks and smoking their pipes about the Monastery: (15)
As of 2015-07-31 21:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (282 votes), past polls