Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How can I add missing XML open tags

by Jim (Curate)
on Dec 03, 2013 at 22:54 UTC ( [id://1065505]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-19 19:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found