you'll never get a clean parse of XML with regular expressions alone. i suggest you try an existing wheel, many of which can be found at the CPAN. for example, XML::libXML, XML::Parser, and XML::SAX. there are many good examples of using these modules here and elsewhere.
oh, i almost forgot XML::Simple, too.
Update: i did forget... you'll get much better replies if you post an example of code and data that explains your problem. you might want to have a look at Perl Monks FAQ for more (and better) information on posting.
~Particle *accelerates* | [reply] |
I would reccomend following particle's advice.
To answer your question however, This REGEX will replace all newlines that are within elements with a space.
$XML_string =~ s/([^>])\n+([^<])/$1 $2/g
John | [reply] [d/l] |