Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: XML / regex - cleaning up attributes

by ikegami (Pope)
on Oct 01, 2010 at 03:25 UTC ( #862894=note: print w/ replies, xml ) Need Help??


in reply to XML / regex - cleaning up attributes

If it was just single quotes, one could come up with a generic solution that works well in most circumstances.

s/(?<!=)'(?![ >])/&apos;/g

However, & is allowed in Windows file names, and that's much trickier to handle generally. Since only one field is likely to hold incorrect data, this problem can be handled easily.

use HTML::Entities qw( encode_entities_numeric ); s/(?<=<app text=')(.*?)(?=' date)/encode_entities_numeric("$1")/eg;


Comment on Re: XML / regex - cleaning up attributes
Select or Download Code
Replies are listed 'Best First'.
Re^2: XML / regex - cleaning up attributes
by ethrbunny (Monk) on Oct 01, 2010 at 16:43 UTC
    These both look v compelling. I'm definitely going to have to spend some time decrypting them.
    Barbie says "regular expressions are hard."

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2015-08-28 08:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (335 votes), past polls