1
2
3
4
5
6
<threads>
<thread>
<date>11.22.3333</date>
<name>Max Mustermann</name>
</thread>
</threads>
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
use 5.010; use strict; use warnings; use XML::LibXML; my $parser = XML::LibXML->new(); my $doc = $parser->parse_string(<<"EOM")->documentElement; <threads> <thread> <date>11.22.3333</date> <name>Max Mustermann</name> </thread> </threads> EOM sub walk { my ($node, $stack) = @_; my @children = $node->findnodes("*"); for my $child (@children) { if (ref ($child) eq "XML::LibXML::Element") { walk($child, [@$stack, $node->nodeName]) } } unless (@children) { say join "/", @$stack, $node->nodeName } } walk($doc, []);
perl -d:ptkdb /tmp/a.pl