Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

samtregar (2699)

  (email not shown publicly)

Journal of samtregar (2699)

Thursday July 22, 2004
05:18 PM

The power of Class::XPath revealed

[ #20000 ]
Class::XPath has turned out to be a very good idea, if I may say so myself. Just now I was working on a change to a Krang element library and Class::XPath saved me a lot of work. I needed to reorganize the element tree and move a subelement one level deeper. Without Class::XPath the code to access this element would probably have been:

$auto = $story->element->child('search_auto');

Which would have to change to:

$auto = $story->element->child('search_auto_container')->child('search_auto');

This would have sucked because that element is used all over the element set. But thanks to Class::XPath the code was:

($auto) = $story->element->match('//search_auto');

This will work no matter where the 'search_auto' element is in the tree, so no change is needed! How cool is that?


The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.