in reply to How to modify an attribute containing special characters in a xml file?

G'day ankit.tayal560,

I suspect your problem lies with backslashes in 'path=' values; and, quite possibly, any other special characters in attribute values.

As an example, consider 'path="...Components\"', where '\"' means a literal quote and don't end the string; that should probably be '\\"', meaning a literal backslash followed by a quote to end the string.

Take a look at quotemeta; note the '\Q' escape (which I personally use more often than the function).

Also see these sections from perlop:

Update: Added a missing quote: \\"''\\"'

— Ken

Replies are listed 'Best First'.
Re^2: How to modify an attribute containing special characters in a xml file?
by ankit.tayal560 (Beadle) on Sep 30, 2016 at 11:41 UTC

    already tried that. don't change a thing ! tried quoting & as \& also but dint worked!

      "... ! tried quoting & as \& also but dint worked!"

      Firstly, see ++Corion's response to you in this thread (to which you replied "ok got your point ...").

      The code I posted in "Syntax-highlight Non-Perl Code for HTML" has, near the start:

      { my %entity_for = qw{& &amp; < &lt; > &gt;}; sub chars_to_ents { $_[0] =~ s/([&<>])/$entity_for{$1}/gr } }

      You'll find usage near the end of the script. Perhaps you could write somethng like this tailored to your needs.

      — Ken