Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems installing HTML::TreeBuilder::XPath on Win32 1

Status
Not open for further replies.

yeddish

IS-IT--Management
Jul 18, 2007
40
US
Hello, everyone!
I am having a problem installing HTML::TreeBuilder::XPath on my Win32 installation of Perl. The package installs fine and installs the one dependency that it has (XML::XPathEngine), but when I try to use itm I get the following error:

Can't locate object method "getElementById" via package "HTML::TreeBuilder::XPath" at C:/Perl/site/lib/XML/XPathEngine/Function.pm line 121.

I've tried installing a few other packages that I thought might fix the problem, but nothing worked.

Any ideas?

Thanks.
-Joel
 
Can you post your code?

Also I don't see any function called getElementById in HTML::TreeBuilder::XPath or HTML::TreeBuilder

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
I can post the code at my lunch break in a couple of hours. It's only a couple of lines at this point. I was mainly testing to see if the package installed correctly.

Also, the problem isn't with the HTML::TB:XPath package, but the XPathEngine package as noted by C:/Perl/site/lib/XML/XPathEngine/Function.pm line 121.

I tried looking at the "use" statements in that file, but I didn't find anything else that it needed.

Thanks.
-Joel
 
Did you install
XML::XPathEngine

?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
If you post what you have I will install the modules and see what I am getting also.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
I did install XML::XPathEngine. PPM actually installed it automatically as a dependency.
Here's my code:

use HTML::TreeBuilder::XPath;
my $tree= HTML::TreeBuilder::XPath->new;
$tree->parse_file( "my $salesGrowth=$tree->findvalue( 'id("area2")/table[2]/tbody/tr[2]/td[2]');
print "$salesGrowth!\n";

Nothin' too fancy.
Thanks, guys.
-Joel
 
It's something to do with what is in the findvalue(). I can manipulate that and get no errors (especially by removing id("area2")

I'm not quite sure what I'm actually doing :) but I can get it to do other things as long as I remove the id("area2") part.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Ok. I was using a compact (sortof) version of the XPath. Maybe if I start my XPath from /html it will work better.
I'll report my findings on this thread when I get it straightened out.
Thanks for the tip!
-Joel
 
No problems.. I figured the least I could do was verify if I was getting the same problems as you.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Ok... When I give it the entire XPath from /html it doesn't give me the error, but it also doesn't access what it should be accessing. I'm not sure why that is.
I'll have to play with it some more.

Thanks for the help, travs69!
-Joel
 
Ok. I think that my problem here is a usage problem at this point. I can't get the module to recognize anything past the second level (/html/body). I posted on a forum that the creator of the package monitors, so we'll see what he says and I'll post it back here.

-Joel
 
Cool... I don't quite understand what it is trying to do or maybe I would have been more help. I'm glad your getting it figured out though.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Well, what I wanted to do was to pull data out of a web page using XPaths. This seems to be the easiest way to do it using Perl.
I was using some other methods, but if the format of the page changed even a little, I would have to rewrite my code. TreeBuilder XPaths use the ids of various tags, so the code is more resilient to changes in the HTML.

If you know of another easy way, I would be interested in giving it a look.

Thanks.
-Joel
 
You might post that as a seperate question to the group and see if you can catch the attention of a few of the other guys. I know anytime I have done it I just used LWP and snipped out out what I needed but it does not adjust to changes easily.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top