1$|=1;
2use XML::Rules;
3
4$xml = <<'*END*';
5<doc>
6 <person>
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>
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
31%rules = (
32	_default => 'content',
33	'^bogus' => undef, # means "ignore"
34	address => sub {delete $_[1]->{_content}; $_[1]},
35	person => 'as array',
36	doc => 'pass no content',
37	foo => sub {print "FOOOOOOOO\n"},
38	'/^.name$/' => sub {print "Found a name!\n"; $_[0] => $_[1]->{_content}},
39);
40
41my $parser = new XML::Rules (
42	rules => \%rules,
43	# other options
44);
45
46my $result = $parser->parsestring($xml);
47
48use Data::Dumper;
49print Dumper($result);