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


in reply to How can I add missing XML open tags

Personally, I'd just do this:  s{<([^/>]+?)/>}{<$1></$1>}g. Only if this didn't work for some peculiar reason would I bother with a more complicated solution.

Jim

UPDATE:  A possibly better alternative:  s{<(\w+)/>}{<$1></$1>}ag. (Notice the /a character set modifier, which is purposeful.)

Replies are listed 'Best First'.
Re^2: How can I add missing XML open tags
by TheVend (Novice) on Dec 04, 2013 at 21:30 UTC
    That was surprisingly very effective. Thanks!

      You're welcome. But you really shouldn't find it "surprisingly very effective." Perl excels at text transformation. XML is text. Changing all occurrences of <foo/> to <foo></foo> in an XML document is a trivial transformation (unless it isn't due to some rare and unlikely edge case).

      Jim