Valid XML only needs & and < to be turned into & and < respectively. You don't have to encode ' " or > at all.
Replacing all & by & is trivial. This still leaves you with the troublesome <, but I don't think there is any possibility (other than validating your XML against a DTD) to let the script differentiate between <FIELDS> and <do_what>: they both look like a "valid" XML tag.
Oh yes, just remembered: ]]> must be encoded as ]]> if you want to use it as text.
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
In reply to Re: regex on XML
by CountZero
in thread regex on XML
by bear0053
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |