Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: creating an XML string

by holli (Abbot)
on Dec 28, 2004 at 18:18 UTC ( [id://417811]=note: print w/replies, xml ) Need Help??


in reply to creating an XML string

change "IBM & Microsoft" into "IBM & Microsoft"?
i assume you mean change "IBM & Microsoft" into "IBM & Microsoft", or even &.

if you know the codes of the chars you want to change, you can do something like the following:
my %ent= ( "&" => 38, "<" => 60, ">" => 62, #... ); $string = "IBM & Microsoft > Sun\n"; print $string; for ( keys %ent ) { $string =~ s/$_/&#$ent{$_};/g } print $string; #prints IBM &#38; Microsoft &#62; Sun
Another option is to put the string in question into a <![CDATA[...]]>-section.

Replies are listed 'Best First'.
Re^2: creating an XML string
by holli (Abbot) on Dec 28, 2004 at 18:19 UTC
    damn. too slow ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-03-19 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found