I'm sestting up TwigHandlers like this (partial code):
... and process_body_hl2 is pretty simple:my $twig = new XML::Twig( TwigHandlers => { 'byline' => \&byline, 'body.head/hedline' => \&hedline, 'body.content/p' => \&process_p, 'body.content/hl2' => \&process_body_hl2, 'body.content/block/p' => \&process_p, 'body.content/block/hl2' => \&process_body_hl2, 'body.content/table' => \&process_table, etc. etc.
Input looks like this:sub process_body_hl2 { my ($t, $hl2) = @_; my $para = crunch($hl2->text); $body .= "<p><b>$para</b></p>"; }
The output for that part comes out like this (this is a different format of xml from the input):<body.content> <hl2 style="section_head">SECTION HEAD</hl2> <hl2 style="subhead">subhead</hl2> <p/>
Where are the <b> tags? Later, the next hl2 in the body looks like this:<body.content> <p>SECTION HEAD</p><p>subhead</p>
And this one comes out the way it should:<p/> <hl2 style="subhead">2nd subhead</hl2>
Now, how come the first two did not work, but the subsequent one did?<p><b>2nd subhead</b></p><p>
In reply to TwigHandlers not always called? by BenHopkins
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |