CDATA in XMLout

S

Stefan Schmidt

Hi@ll !

I have an application where the items of each XML value are placed in an
array like this:

my $result = transfer({ FIELD1 => 'value1',
FIELD2 => 0,
FIELD3 => "something other"
....

the function api itselfs does something like this:
sub transfer {
my ($arg) = @_
....

my $body = XMLout($arg,
someothervalue => 1,
andanothervalue => 2);

The result of this is something like this:
<request>
<FIELD1>value1</FIELD1>
<FIELD2>0</FIELD2>
<FIELD3>something other</FIELD3>
....
</request>

This works fantastic until today where i have to put more than plain text to
e.g. the FIELD3.
Now it is so that i have to paste a complete html side to the server where
this call is send to. The server itself only accepted the html data if it is
sent by an CDATA call.

I've done the following:
1.) wrote a template.html file where a complete html side is stored in.
2.) added the following:
open(CONTENT, '../includes/template1.html');
@content = <CONTENT>;
3.) modified the "my $result" like this:
my $result = transfer({ FIELD1 => 'value1',
FIELD2 => 0,
FIELD3 => "<![CDATA[ @content ]]>";

If i execute the script now the result looks like this:
<request>
<FIELD1>value1</FIELD1>
<FIELD2>0</FIELD2>
<FIELD3>&lt;![CDATA[ **the complete html template with encoded
source** ]]&gt;</FIELD3>
....

Can someone give me any hint how i can escape the < so that the XML Parser
don't touch it ?! The \ doesn't work very well :-(

kind regards
stefan
 
A

Andy R

Stefan Schmidt said:
Hi@ll !


Can someone give me any hint how i can escape the < so that the XML Parser
don't touch it ?! The \ doesn't work very well :-(

kind regards
stefan

Try using the option: NoEscape => 1 in your XMLout call. Should work, but
not tested it.

Andy R
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top