This seems to do the job:
#!/usr/bin/env perl use strict; use warnings; use XML::LibXML 2; my $xml = "XML::LibXML"->load_xml(location => "input.xml"); for my $hg ($xml->findnodes('//host-group')) { my $path = join ".", $hg->findnodes('ancestor-or-self::host-group' +)->map(sub { $_->{name} }); my @ips = $hg->findnodes('ip-address-ranges')->map(sub { split /\ +s*,\s*/, $_->textContent }); print "$path\t$_\n" for @ips; }
In reply to Re: Nested XML Question
by tobyink
in thread Nested XML Question
by zelet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |