#!/usr/bin/perl -w
use strict; 
use diagnostics;

# This example uses Tree::DAG_Node::XPath directly
# it creates a simple tree, with a root and 5 daughters
# then uses XPath to select 2 of those dautghters by name

use Tree::DAG_Node::XPath;

# create the tree
my $root = Tree::DAG_Node::XPath->new();
$root->name("root_node");

foreach (1..5)
  { my $new_daughter = $root->new_daughter;
    $new_daughter->name("daugther$_");
  }

# now use XPath to find nodes
my $roots= $root->find( '/root_node');
foreach (@$roots) { print "found root: ", $_->name, "\n"; }

my $daughters= $root->find( '/root_node/daugther2 | /root_node/daugther4');
foreach (@$daughters) { print "found daughter: ", $_->name, "\n"; }
