Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by Corion (Patriarch)
on Sep 30, 2016 at 10:34 UTC ( [id://1172985]=note: print w/replies, xml ) Need Help??


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

What do you expect?

& is a special character in XML and a literal & needs to be encoded as & in XML. Maybe you did not want &#xA in your original string but something else?

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:07 UTC

    ok got your point but I want that expression only in my string . any suggestions regarding how should I proceed??

      You will need to learn about ampersand-encoding and XML then. I guess that 
 is already encoded and the 
 stands for the character \x0A in Perl parlance. So you will need to change your initial string to:

      my $string="Johnson Controls Automotive Electronics\x0APackage: GMLAN +3.1 - Single Channel\x0AMicro: uPD70F3524\x0ACompiler: Green Hills 5. +1.7-BD1110030";

      or, in a more sensible fashion:

      my $string= join "\n", "Johnson Controls Automotive Electronics", "Package: GMLAN 3.1 - Single Channel", "Micro: uPD70F3524", "Compiler: Green Hills 5.1.7-BD1110030";

      I guess that the original text contains line breaks and you want to preserve them.

        Hi Corion, Thanks a lot ! I was scratching my head on that problem for so long. your solution works perfectly.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (8)
As of 2024-04-19 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found