Mirod,

----- Original Message ----- From: "mirod" <[EMAIL PROTECTED]>
To: <beginners@perl.org>
Sent: Monday, July 23, 2007 12:42 PM
Subject: Re: Parsing large XML file - Revisited


On Jul 22, 3:33 am, [EMAIL PROTECTED] (Dr.Ruud) wrote:
"Mike Blezien" schreef:

>   my $article_number = $elt->first_child_text('article_number');
>   my $dist_number    = $elt->first_child_text('distributor_number');
>   my $dist_name      = $elt->first_child_text('distributor_name');
>   my $artist         = $elt->first_child_text('artist');
>   my $ean_upc        = $elt->first_child_text('ean_upc');
>   my $set_total      = $elt->first_child_text('set_total');

That looks awful. Isn't there some way with the module to do it cleaner?

Or do it more like:

  my @text_tags = qw(article_number distributor_number etc);
  my %data;

  for my $tag (@text_tags) {
      $data{_text}{$tag} = $elt->first_child_text($tag);
  }

just a quick note, that first_child_text can also be written field,
which often
makes more sense in a data oriented context.

--
mirod

that was an excellent idea :) Alot cleaner and alot less coding involved. Still fairly new working with XML parsing.

Mike
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to