I have a file that looks like this
====
<FNAME>joe</FNAME>
<SURNAME>bloggs</BLOGGS>
<QDETAILS> herein lies the question posed by the user
the question can be multi-lined
like this one.
</QDETAILS>
======
I'm trying to read the various tag content into variables:
==========
sub ParseFile {
my $file = 'submission6.xml';
#opened the file i want to parse
open(FH, $file) || die "cannot open file: $!";
print "opening $file...........\n\n";
#read contents into array
my @stuff=<FH>;
close(FH);
#create one long string - why I'm not sure - but it worked with the regex
below
foreach my $stuff(@stuff) {
$var=$var.$stuff;
}
my @details;
# this grabs the text between <FNAME> and </FNAME>
($details[0])=$var=~/\<FNAME\>(.*)\<\/FNAME\>/;
# this grabs the text between <SURNAME> and </SURNAME>
($details[1])=$var=~/\<SURNAME\>(.*)\<\/SURNAME\>/;
#I want this top grab all the text between <QDETAILS> and </QDETAILS>
-newline characters included.
($details[2])=$var=~/\<QDETAILS\>(.*)\<\/QDETAILS\>/;#
#PROBLEM IS HERE==================^^^
foreach $detail(@details) {
print "$detail\n";
}
}
==========
the regex for FNAME and SURNAME work fine. But I can't grab the text between
<QDETAILS> and </QDETAILS> because
of newline characters I think.
Any other tips on how to improve my code generally?
Please help.
Thanks,
J
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]