Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Regular expression

by repellent (Priest)
on Feb 05, 2012 at 03:46 UTC ( #951898=note: print w/ replies, xml ) Need Help??


in reply to Regular expression

use XML::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>


Comment on Re: Regular expression
Select or Download Code
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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2015-07-03 03:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls