Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: XML::Twig generating invalid XHTML output??

by ikegami (Patriarch)
on Feb 14, 2005 at 17:55 UTC ( [id://430877]=note: print w/replies, xml ) Need Help??


in reply to Re^2: XML::Twig generating invalid XHTML output??
in thread XML::Twig generating invalid XHTML output??

Could it be that you're suppose to use twig_handlers instead of twig_roots, since you don't want body to become a root node? The example from the module's documentation is: (irrelevant details omitted)

my $twig=XML::Twig->new( twig_handlers => { title => sub { $_->set_gi('h2') }, # Change title tags to h2. para => sub { $_->set_gi('p') }, # Change para to p. hidden => sub { $_->delete; }, # Remove hidden elements. list => \&my_list_process, # Process list elements. }, pretty_print => 'indented', # Output will be nicely formatted. );

Replies are listed 'Best First'.
Re^4: XML::Twig generating invalid XHTML output??
by nick (Sexton) on Feb 14, 2005 at 17:59 UTC
    Looks like that works too! Hmmm. I've read places which suggest using handlers, and others that suggest roots, wonder why/which is better?
    
    - Nick
    
      The difference appears to be what they generate. root is good if you want to extract portions of an XML doc (because it skips the stuff outside the roots), whereas handlers appear to be the way to go to transform an XML doc. At least, that's what I deduced, having no experience with XML::Twig before now.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://430877]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-07-25 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.