1$|=1;
2use XML::Rules;
3
4$xml = <<'*END*';
5<doc boo="789">
6 <person active="1">
7  <fname>Jane</fname>
8  <lname>Luser</lname>
9  <email>JLuser@bogus.com</email>
10  <address>
11   <street>Washington st.</street>
12   <city>Old Creek</city>
13   <country>The US</country>
14   <bogus>bleargh</bogus>
15  </address>
16 </person>
17 <person active="0">
18  <fname>John</fname>
19  <lname>Other</lname>
20  <email>JOther@silly.com</email>
21  <address>
22   <street>Grant's st.</street>
23   <city>New Creek</city>
24   <country>Canada</country>
25   <bogus>sdrysdfgtyh <foo>degtrhy werthy</foo> drthyu</bogus>
26  </address>
27 </person>
28</doc>
29*END*
30
31my $parser = new XML::Rules (
32	rules => [
33		'^bogus' => undef, # means "ignore". The subtags ARE NOT processed.
34		'^person' => sub {
35			return $_[1]->{active};
36		},
37		email => sub {$_[1]->{_content} = lc($_[1]->{_content}); return $_[0] => $_[1]}
38	],
39	style => 'filter'
40	# other options
41);
42
43$parser->filterstring($xml, \*STDOUT);
44