Throughout my life, I canβt understand the XML :: Twig documentation for entity processing.
I have XML that I generate using HTML :: Tidy. The call is as follows:
my $tidy = HTML::Tidy->new({ 'indent' => 1, 'break-before-br' => 1, 'output-xhtml' => 0, 'output-xml' => 1, 'char-encoding' => 'raw', }); $str = "foo bar"; $xml = $tidy->clean("<xml>$str</xml>");
which produces:
<html> <head> <meta content="tidyp for Linux (v1.02), see www.w3.org" name="generator" /> <title></title> </head> <body>foo bar</body> </html>
XML :: Twig (understandable) barfs on . I want to do some conversions by executing them through XML :: Twig:
my $twig = XML::Twig->new( twig_handlers => {... handlers ...} ); $twig->parse($xml);
String line $twig->parse on , but I canβt figure out how to add the programmatically. I tried things like:
my $entity = XML::Twig::Entity->new("nbsp", " "); $twig->entity_list->add($entity); $twig->parse($xml);
... but without joy.
Please help =)
source share