Posted on 2008-12-25 08:51:55-08 by selvaperumaal
How I can get last child of an element through Twig Handler
Hi, I have trying to get last child of an element using twig object by,
@last_tg=$t->get_xpath(tbody/row[last()]/entry);
its work well, but I need it in twig handler potion as
my $t = new XML::Twig ( twig_handlers => {'tbody/row[last()]/entry' => sub {$_->set_att('aid5:cellstyle'=>'TBL')} );
but it shows error like 'unrecognized expression in handler', is it possible using the 'last()' xpath function here? give me an idea for how I can get last child of an element through Twig Handler. Thanks in advance.
Direct Responses: 9600 | Write a response
Posted on 2008-12-26 02:29:54-08 by mirod in response to 9599
Re: How I can get last child of an element through Twig Handler

No, you can't use last() here. There is no way for the parser, at that point, to know that the child is the last one. You will have to set a handler on the parent (tbody here), and then you can access the last child.

Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.