tracekill has asked for the wisdom of the Perl Monks concerning the following question:
In the commented section is my previous implementation of an HTML::Reader solution. Uncommented is the author's suggestion of a possible solution after I contacted him with my problem. Any help is greatly appreciated and will be rewarded with over-the-top praise and adoration.my @xmlfiles = (); opendir(DIR, $self->{dirtree}->GetSelectedPath()) || die "Cannot o +pen selected path. Make sure a path is selected!"; @xmlfiles = grep(/\.xml$/, readdir(DIR)); closedir(DIR); my $xmlreader; my $showerr = 0; my @taglist = (); # For every XML file in our list... for(my $count = 0; $count < @xmlfiles; $count++){ # Create an XML reader for that file, get all the tag data int +o an array then add only relevant tag data # to the @taglist array. # $xmlreader = new HTML::TagReader $self->{dirtree}->GetSelect +edPath() . "\\" . $xmlfiles[$count]; # my @tagarr = $xmlreader->gettag($showerr); # for(my $subcount = 0; $subcount < @tagarr; $subcount++){ # push(@taglist, $tagarr[$subcount*3]); # } my $infile = $self->{dirtree}->GetSelectedPath() . "\\" . $xml +files[$count]; my %removedumplicate; my @tagarr; my $p=new HTML::TagReader $infile; while(@tagarr = $p->getbytoken(!my $opt_W)){ my $origtag =$tagarr[0]; if($tagarr[1] eq "" || $tagarr[1] eq "!--"){ next; } if ($removedumplicate{$tagarr[0]}){ next; } push(@taglist, $tagarr[0]); $removedumplicate{$tagarr[0]}++; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Retrieving a List of XML Tag Names from Given File
by graff (Chancellor) on Jul 21, 2009 at 05:17 UTC | |
|
Re: Retrieving a List of XML Tag Names from Given File
by ikegami (Patriarch) on Jul 20, 2009 at 23:24 UTC | |
|
Re: Retrieving a List of XML Tag Names from Given File
by grantm (Parson) on Jul 21, 2009 at 03:09 UTC |