F
Faith Greenwood
I'm very confused. I'm pulling some numbers from an xml file and then
trying to do some math.
####XML File
<library>
<books>5</books>
<pages>12</pages>
</library>
####Code
#!/usr/bin/perl
use strict;
use warnings;
use XML::LibXML;
use XML::XPath;
my $parser=XML::LibXML->new();
my $doc=$parser->parse_file("C:/scripts/production/xml.xml");
my $books=$doc->find("//books/text()");
my $pages=$doc->find("//pages/text()");
print "$books\n";
print "$pages\n";
my $total_pages=$books * $pages;
########################
when I run the above code, I get the output:
5
12
Operation "*": no method found,
left argument in overloaded package XML::LibXML::Nodelist,
right argument in overloaded package XML::LibXML::Nodelist at
script.pl line 16
Why can't I do math operations here?
thx!
trying to do some math.
####XML File
<library>
<books>5</books>
<pages>12</pages>
</library>
####Code
#!/usr/bin/perl
use strict;
use warnings;
use XML::LibXML;
use XML::XPath;
my $parser=XML::LibXML->new();
my $doc=$parser->parse_file("C:/scripts/production/xml.xml");
my $books=$doc->find("//books/text()");
my $pages=$doc->find("//pages/text()");
print "$books\n";
print "$pages\n";
my $total_pages=$books * $pages;
########################
when I run the above code, I get the output:
5
12
Operation "*": no method found,
left argument in overloaded package XML::LibXML::Nodelist,
right argument in overloaded package XML::LibXML::Nodelist at
script.pl line 16
Why can't I do math operations here?
thx!