My XML file is like below: <reference> ... ... <title type="journal">Harv L R</title> .... .... </reference>
My INI file info is like below:
Harv L R<TAB>Harvard Law Review
MLR<TAB>Modern Law Review
The required output is as follow:
<reference>
...
...
<title type="journal">Harvard Law Review</title>
....
....
</reference>
The <title> is present in other locations also. We have to modify only
titles which are child to <reference> and type="journal".
My code is like below:
use XML::XPath;
use XML::XPath::XMLParser;
$xp = XML::XPath->new(filename => 'mlr_648.xml');
$nodeset = $xp->find('//reference/[EMAIL PROTECTED]"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";
}
}
}
I am getting required output. but I am unable to print entire XML with
the modification in a separate file. Please help in two cases.
1. Print an error message if the corresponding full name is not found.
2. Print entire XML to a separate file.
I have attached sourcecode, and ini file also.
gae.pl
Description: Perl program
mlr.dat
Description: Binary data
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
