##
use warnings;
use strict;
use XML::XPath;
use XML::XPath::XMLParser;
my $xmlFile = "try.xml";
# create an object to parse the file and field XPath queries
my $xpath = XML::XPath->new(filename => $xmlFile) || die "Problem: $!\n";
# look for the preceding sibling node to the one in question
my $nodeset = $xpath->find('//*[@id=' . "'id4']/preceding-sibling::*[1]");
foreach my $node ( $nodeset->get_nodelist ) {
print XML::XPath::XMLParser::as_string( $node ) . "\n";
}