Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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
Replies are listed 'Best First'.
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 making s'mores by the fire in the courtyard of the Monastery: (15)
As of 2015-07-31 13:33 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 (277 votes), past polls