Z
zeelani
Hi,
I am trying to find out how can I read a value between the start and
end tags in an XML file in perl.
If I have <Hotel ID = "123" name = "Marriott"></Hotel>
I can read this using
#!/usr/bin/perl
use XML:
arser;
$parser = new XML:
arser(Style => 'Stream');
$parser->parsefile('abc.xml');
print "$Hotel_id\n", "$Hotel_name\n";
sub StartTag {
my $Handler = shift(@_);
my $Name = shift(@_);
my %Attr = %_;
if($Name eq 'Hotel') {
$Hotel_id = $Attr{'id'};
$Hotel_name = $Attr{'name'};
}
sub Text {
$TheText = $_ ;
}
sub EndTag
{
if($Name eq 'Hotel'){
exit(0) };
But if I have
<Hotel>Marriott</Hotel><br>
I am not sure how to read "Marriott" in perl. Does anyone have any
ideas?
Thanks a lot,
Zeelani.
I am trying to find out how can I read a value between the start and
end tags in an XML file in perl.
If I have <Hotel ID = "123" name = "Marriott"></Hotel>
I can read this using
#!/usr/bin/perl
use XML:
$parser = new XML:
$parser->parsefile('abc.xml');
print "$Hotel_id\n", "$Hotel_name\n";
sub StartTag {
my $Handler = shift(@_);
my $Name = shift(@_);
my %Attr = %_;
if($Name eq 'Hotel') {
$Hotel_id = $Attr{'id'};
$Hotel_name = $Attr{'name'};
}
sub Text {
$TheText = $_ ;
}
sub EndTag
{
if($Name eq 'Hotel'){
exit(0) };
But if I have
<Hotel>Marriott</Hotel><br>
I am not sure how to read "Marriott" in perl. Does anyone have any
ideas?
Thanks a lot,
Zeelani.