Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

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


in reply to Re^2: How to modify an attribute containing special characters in a xml file?
in thread How to modify an attribute containing special characters in a xml file?

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.

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

    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://1172988]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found