wstarrs has asked for the wisdom of the Perl Monks concerning the following question:
Now what I need is the parsing routine to look inside the main Item (Whatever in this case) and then retrieve the values from the nested items and put them into a value array inside a hash key (i.e. %hash{Name}{ValueArray}) I have tried a few different setups and I cannot seem to get it right, it appears to work ok if only one of the nested items has a value (they are from checkboxes) however if they both have a value the program reads the first one into the array and stops. Another issue is the fact that I am having trouble regulating the loops to only look inside this main item. Here is two samples of things I have tried, any suggestions would be appreciated:<Item Name="Whatever"> <replicant field> <NestedItem1> <Value1 = "One"> <NestedItem2> <value2 = "Two"> <End replicant> <End "whatever" item>
ANDif ($item_name eq "LinkLocation") { $i = 0; $temp_token = $p->get_token; while (!($temp_token->[0] eq "E") && ($i < 3)) { if (($temp_token->[1] eq "item")) { $temp_dcr{$dcr_name}{Location}[$i] = $p->get_trimmed_text("/va +lue"); $i++; } $temp_token = $p->get_token; } $found++; }
Thanks, Billif ($item_name eq "Show Link") { $temp_token = $p->get_token; while (!(($temp_token->[0] eq "E") && ($temp_token->[1] eq "item") +)) { if (($temp_token->[0] eq "S") && ($temp_token->[1] eq "value" +)) { for ($i=0;$i<2;) { $temp_token = $p->get_tag("item"); $temp_dcr{$dcr_name}{Location}[$i] = $p->get_trimmed_text( +"/item"); $i++; } $temp_token = $p->get_token; } } $found++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing Issues
by Beatnik (Parson) on May 24, 2001 at 02:45 UTC |