Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Creation of Hash necessary?

by poj (Priest)
on Aug 14, 2014 at 08:51 UTC ( #1097400=note: print w/ replies, xml ) Need Help??


in reply to Creation of Hash necessary?

If your data was well formed XML you could use XML::Twig

#!perl use strict; use XML::Twig; my $xml = do { local $/; <DATA> }; my $twig = new XML::Twig( twig_handlers =>{ class => \&class}, ); $twig->parse($xml); sub class { my ($t,$elt) = @_; for my $shape ($elt->children){ $shape->set_att('class',$elt->att('id')); $shape->print; print "\n"; } } __DATA__ <data> <class id="abc"> <polygon coordinates=".."/> <polygon coordinates=".."/> <rectangle coordinates=".."/> </class> <class id="def"> <polygon coordinates=".."/> <rectangle coordinates=".."/> <rectangle coordinates=".."/> </class> </data>
poj


Comment on Re: Creation of Hash necessary?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2014-10-22 02:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (112 votes), past polls