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

Re: extracting attribute values which might have multiple occurences from xml file

by poj (Priest)
on Aug 20, 2013 at 09:07 UTC ( #1050156=note: print w/ replies, xml ) Need Help??


in reply to extracting attribute values which might have multiple occurences from xml file

#!perl use strict; use warnings; use XML::Simple; use Data::Dump 'pp'; # input my $xml1 = infile('test.xml'); # process my $data = XMLin($xml1,keyattr => []); pp $data; # output for (@{$data->{'httpsRoute'}}){ print << "EOF"; Host = $_->{'hostname'} Environment = $_->{'environment'} Key = $_->{'key'} EOF } sub infile { my $filename = shift; local $/; #open IN,'<',$filename or die "Could not open $filename $!"; my $xml = <DATA>; # or IN return $xml; } __DATA__ <xml> <httpsRoute hostname="abchostname1.xxx.com" port="443" environment="QA +"> <key>6924</key> </httpsRoute> <httpsRoute hostname="hostname3.xxx.com" port="7416" environment="CAT" +> <key>9990068</key> </httpsRoute> </xml>
poj


Comment on Re: extracting attribute values which might have multiple occurences from xml file
Download Code
Re^2: extracting attribute values which might have multiple occurences from xml file
by tinkuPerlMonk2 (Initiate) on Aug 20, 2013 at 13:16 UTC
    thank you very much poj!. This helps to a great extent to get started for the folks like me who are starters of perl scripting. Thank you again very much!!!!!!!!!!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-09-17 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (56 votes), past polls