Dear Monks (whether ye be Monker, Monked, or Monkee):
I'm sestting up TwigHandlers like this (partial code):
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.
... and process_body_hl2 is pretty simple:
sub process_body_hl2 {
my ($t, $hl2) = @_;
my $para = crunch($hl2->text);
$body .= "<p><b>$para</b></p>";
}
Input looks like this:
<body.content>
<hl2 style="section_head">SECTION HEAD</hl2>
<hl2 style="subhead">subhead</hl2>
<p/>
The output for that part comes out like this (this is a different format of xml from the input):
<body.content>
<p>SECTION HEAD</p><p>subhead</p>
Where are the
<b> tags? Later, the next hl2 in the body looks like this:
<p/>
<hl2 style="subhead">2nd subhead</hl2>
And this one comes out the way it should:
<p><b>2nd subhead</b></p><p>
Now, how come the first
two did
not work, but the subsequent one did?