use strict; use warnings; use XML::LibXML; my $searchterm="THESEUS"; my $file="c:\\webroot\\dream.xml"; #Get the XML file my $parse = XML::LibXML->new; my $doc = $parse->parse_file($file); my %releventlines; #Search through and find the correct field my %act; my $scene = $doc->findvalue('//PLAY//ACT//TITLE'); foreach $scene (keys %act) { my $item = $doc->findnodes('//PLAY//SCENE//SPEECH'); #Finding the speaker my $speech = $item->findvalue('SPEAKER'); next unless $speech eq $searchterm; my $text = $item->findvalue('LINE'); $text = $act{$scene}; } print $scene . "\n"; #### Act 1 SCENE I. Athens. The palace of THESEUS. THESEUS Now, fair Hippolyta, our nuptial hour Draws on apace; four happy days bring in