CDATA in XMLout

Discussion in 'Perl' started by Stefan Schmidt, Dec 28, 2003.

  1. 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
     
    Stefan Schmidt, Dec 28, 2003
    #1
    1. Advertising

  2. Stefan Schmidt

    Andy R Guest

    "Stefan Schmidt" <> wrote in message
    news:bsnpsa$v4f$...
    > 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
     
    Andy R, Dec 31, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. chrisn
    Replies:
    1
    Views:
    3,633
    Bruce Barker
    Sep 13, 2005
  2. Forest
    Replies:
    0
    Views:
    326
    Forest
    Oct 20, 2003
  3. John Davison
    Replies:
    1
    Views:
    624
    Hal Rosser
    Jul 7, 2004
  4. Replies:
    3
    Views:
    779
    Joe Kesselman
    Mar 6, 2006
  5. pt
    Replies:
    3
    Views:
    536
Loading...

Share This Page