in reply to Re: xml parsing without using cpan modules
in thread xml parsing without using cpan modules

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^2: xml parsing without using cpan modules

Replies are listed 'Best First'.
Re^3: xml parsing without using cpan modules
by Scarborough (Hermit) on Aug 10, 2004 at 16:07 UTC
    As I indecated this is a low dirty way of extracting certain bits of data from an XML file. It might give you some help but I wont be holding my breath

    use strict; use Data::Dumper; my @jobs; my $key; my $value; while (my $line = <DATA>){ if ($line =~ /\<name\>(.*)\<\/name\>/){$key = $1;} if ($line =~ /\<time\>(.*)\<\/time\>/){$value=$1;} if ($key and $value){push @jobs, {$key=>$value}; $key = undef; $v +alue = undef;} } print Dumper(\@jobs); __DATA__ <mainprofile> <job> <name>myjob1</name> <time>14:30</time> <dist>lend</dist> </job> <job> <name>myjob2</name> <time>14:33</time> <dist>fin</dist> </job> </mainprofile>
    As I said XML::Simple is what I'd use now.
    Good Luck