Output:use XML::Smart ; my $XML = new XML::Smart(q{ <html> <head> <title> test </title> </head> <body bgcolor='red' > <errors> <TMPL_IF NAME='INVALID_WIDGET_SIZE' > waka waka </TMPL_IF> <TMPL_IF NAME='INVALID_WIDGET_COLOR' > waka waka waka </TM +PL_IF> </errors> <table> <tr colspan='2'> <td> text </td> <td> text2 </td> </tr> </table> </body> </html> } , XML::Smart::Parser) ; print $XML->data(wild=>1 , noheader=>1) ;
But note that XML and HTML are different! One thing you can see is the order of the tags and the title that works like an attribute. You can control how the data() method will trate the entry as an attribute or node with some extra flags, but is not good to do this always! I think that the best option is to use some HTML::* module like HTML::TokeParser, as other monks already have said.<html> <body bgcolor="red"> <errors> <TMPL_IF NAME="INVALID_WIDGET_SIZE"> waka waka </TMPL_IF> <TMPL_IF NAME="INVALID_WIDGET_COLOR"> waka waka waka </TMPL_IF> </errors> <table> <tr colspan="2"> <td> text </td> <td> text2 </td> </tr> </table> </body> <head title=" test "/> </html>
Graciliano M. P.
"The creativity is the expression of the liberty".
In reply to Re: XML::Simple problem, or How to convert HTML to Perl and then back again.
by gmpassos
in thread XML::Simple problem, or How to convert HTML to Perl and then back again.
by Wonko the sane
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |