in reply to Regular expression - parsing and xml string

Try changing your while regex to something like:

while($xml=~m/\<(.+?)(\s.*?)?\>(.+?)\<\/\1\>/sig){

and then $2 is your attributes and $3 is your element body.

You also might consider one of the various XML parsing modules available from CPAN like XML::Simple for instance. Robust XML parsing is not simple - there are just so many details that can trip you up.