in reply to Why doesn't non-greediness work?
It works, but i had to 'XML-ize' the image tags first. I wrapped the img tags inside a tags simply to show that other tags are outputted 'as-is'. Also, a big ++ to broquaint for helping get this right. I was trying to create a new XML::Twig::Elt object with 'CDATA' as the first arg. This created a <CDATA> tag pair - broquaint changed that to '#CDATA', which led me to the correct argument ... '#PCDATA'. Confusing? Start studying! ;)use strict; use warnings; use XML::Twig; my $twig = XML::Twig->new( twig_handlers => { 'img[@alt="Smiley"]' => sub { XML::Twig::Elt->new('#PCDATA',':)')->replace($_) }, 'img[@alt="Wink"]' => sub { XML::Twig::Elt->new('#PCDATA',';)')->replace($_) }, }, pretty_print => 'indented', ); $twig->parse(\*DATA); $twig->flush; __DATA__ <body> <a href="wink.html"> <img border="0" src="/images/wink.gif" alt="Wink"/> </a> <a href="smile.html"> <img border="0" src="/images/smiley.gif" alt="Smiley"/> </a> </body>
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: Why doens't non-greediness work?
by Tomte (Priest) on May 10, 2003 at 20:49 UTC | |
|
Re: (jeffa) Re: Why doens't non-greediness work?
by mirod (Canon) on May 11, 2003 at 05:51 UTC | |
|
Re^2: Why doesn't non-greediness work? (HTML::TokeParser::Simple)
by Aristotle (Chancellor) on May 11, 2003 at 11:54 UTC |