use XML::XPath;
use XML::XPath::XMLParser;

$xp = XML::XPath->new(filename => 'mlr_648.xml');
$nodeset = $xp->find('//reference/title[@type="journal"]');
foreach my $node ($nodeset->get_nodelist) 
{
    $line=XML::XPath::XMLParser::as_string($node);
    if($line =~m!<title type="journal">(.*)</title>!)
    {	
	$jb = $1;
    }
    &rep($jb);
}

sub rep 
{
    $jabb = $jb;
    open(DAT, "mlr.dat");
    $/=undef;
    $x=<DAT>;
    while($x=~m!(.*)\t(.*)!ig)
    {
	%data = ("$1" => "$2");
	$jname = $data{$jabb};
	if($jname ne "")
	{
	    print "<title type=\"journal\">$jname</title>\n";
	}
    }

}

