parse_file doesn't do what you think it does. Instead it does what it says, it parses a file ;--). So HTML::TreeBuilder::XPath looks for a file named 'http://moneycentral.msn.com/investor/invsub/results/compare.asp?Page=TenYearSum' and doesn't find it, hence returning a quasi empty tree (the html, head and body elements).
You need to load the HTML yourself, for example by using LWP::Simple, and doing this:
Does this help?
parse_file doesn't do what you think, but, as usual, what it says ;--) It parses a file, not a string. So this time it tries to parse a file with avery, very long name, full of pointy brackets, with the same result as your previous attempt. Replace parse_file by parse and you'll be all set.
A couple more things:
- what you should have printed, in order to check that the tree was properly created, is not $html, but $tree->as_HTML,
- always, ALWAYS, use strict, and most of the time use warnings, that will save you a lot aggravation
when you develop