http://qs1969.pair.com?node_id=951898


in reply to Regular expression

useXML::Twig;
XML::Twig->new( twig_handlers => { span => sub { $_->replace_with($_->children_copy) }, }, )->parse(<<'XML')->print; <d> <span> foobar <span> <baz>bax</baz> <span style="color:#000000;"> <ix:nonNumeric name="uk-bus:PrincipalLocation-CityOrTown">Lond +on</ix:nonNumeric> </span> </span> </span> </d> XML print "\n"; __END__ <d> foobar <baz>bax</baz><ix:nonNumeric name="uk-bus:PrincipalLocation-CityOr +Town">London</ix:nonNumeric></d>

Replies are listed 'Best First'.
Re^2: Regular expression
by mirod (Canon) on Feb 05, 2012 at 08:05 UTC

    If the input is not well-formed XML but HTML, you can use parse_html instead of parse in order to internally convert the HTML to XHTML before processing.