Thread Text nach Tags durchsuchen (9 answers)
Opened by roooot at 2009-07-23 21:11

topeg
 2009-07-23 23:50
#123534 #123534
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
Dass sollte ein brauchbarer Ansatz sein:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;
use XML::Simple;

my $tree=XMLin('test.svg');
my @texte=match_text($tree);
print Dumper(\@texte);


sub match_text
{
  my $ref=shift;
  my @list;
  if(ref($ref) eq 'ARRAY')
  { push(@list,match_text($_)) for(@$ref); }
  elsif(ref($ref) eq 'HASH')
  {
    if(exists($ref->{text}))
    {
      if(ref($ref->{text}) eq 'ARRAY')
      { push(@list,$_) for(@{$ref->{text}}); }
      elsif(ref($ref->{text}) eq 'HASH')
      { push(@list,$ref->{text}); }
    }
    push(@list,match_text($ref->{$_})) for(keys(%$ref))
  }
  return @list;
}

View full thread Text nach Tags durchsuchen