#!/usr/bin/perl use warnings; use strict; use diagnostics; use XML::Parser; # This is the ant build file my $antFile = "/home/perlmoth/build.xml"; my $p = XML::Parser->new(Style => 'Tree'); my $doc = $p->parsefile( $antFile ); print "digraph G {\n\n"; process_node(@$doc); print "\n\n}"; sub process_node { my ($type, $content) = @_; if ($type) { my $attrs = shift @$content; if ($type eq 'target') { my @dependencies = split(/,/, $attrs->{depends}); foreach (@dependencies) { print " $attrs->{name} -> $_\n"; } } while (my @node = splice(@$content, 0, 2)) { process_node (@node); } } }