in reply to Naive idea : using XSH with WWW::Mechanize::Firefox, to make faster XPath queries ?

Who says the XPath evaluation and data structures have to be done in pure Perl? Install HTML::TreeBuilder::LibXML.
  • Comment on Re: Naive idea : using XSH with WWW::Mechanize::Firefox, to make faster XPath queries ?

Replies are listed 'Best First'.
Re^2: Naive idea : using XSH with WWW::Mechanize::Firefox, to make faster XPath queries ?
by mascip (Pilgrim) on Feb 06, 2012 at 11:42 UTC

    Thanks for pointing at this library.
    But then i guess that, as this HTML::TreeBuilder::LibXML library seems to parse only the HTML content, i lose the advantage of WWW::Mechanize::Firefox, which is to take Javascript into consideration.

    Just for the sake of curiosity, the Tree look_downs() and the Xpath queries seem to then parse exactly the same information here (the HTML source code); i am wondering whether there is any advantage in using XPath queries rather than Tree's look_down() ? Is it not exactly equivalent ? I guess the XPath queries take less lines to write, though.
    Please tell me when i'm wrong :o)

      i lose the advantage of WWW::Mechanize::Firefox
      You don't. Navigate with Mechanize, parse/query with TreeBuilder.

        As said here 951038 by Corion :
        "WWW::Mechanize::Firefox only works with Firefox. There is no way to make HTML::TreeBuilder::XPath objects work with it."

        WWW::Mechanize::Firefox->xpath() returns MozRepl::RemoteObject, which are i think internal (to Firefox) Javascript objects.
        While HTML:TreeBuilder::XPath returns and deals with HTML::Element, which are extracted from the HTML source, and thus don't take Javascript into account.
        Is that right?

        I am still curious about the utility of using both XPath and Tree. Is it any different from using a Tree on its own?