[Xml-compile] XML document as an embedded CData section

Christopher Taranto christopher at tokpela.com
Wed Sep 5 03:40:27 GMT 2018


Hi Mark,

Thank you for your reply!  Sorry for the delay in responding back to you.

>> Can you try this?
>> my $cdata = $doc->createCDATASection($content);
>> my @req_params = (parameters => { xml => $cdata });

I tried this and it worked perfectly!  Nice that it was so easy.

Just for the record, to make it super simple - I actually did this:

use XML::LibXML;
use File::Slurp;

my $xml_content = read_file($filepath, { binmode => 'utf8' });
my $cdata_node = XML::LibXML::CDATASection->new( $xml_content );
my @req_params = (parameters => { xml => $cdata_node });

Thank you again for your help and also all that you have done!

Kind regards,

Christopher Taranto

On Thu, Aug 30, 2018 at 11:38 PM Mark Overmeer <solutions at overmeer.net>
wrote:

>
> Hi Chris,
>
> * Christopher Taranto (christopher at tokpela.com) [180830 19:19]:
> > How do you post an XML document as an embedded CData section?
> >
> > My test script is receiving a 500 server error because the XML that I am
> > sending is being escaped before it is being sent to the server.
>
> Of course it get escaped, to avoid the confusion between the documents.
> Probably, the server is sloppy in its implementation only expecting CDATA
> from its parser.  CDATA is the better option in this case, but not the
> only option.
>
> > I have looked all over the documentation for many of the different
> modules
> > but I have not been able to find anything that has helped me.
>
> On many places where you add elements or attributes, you can not
> only pass values but also objects.  For instance, a fully prepared
> XML::LibXML::Element object.  You could try to pass a CDATA object.
> (If it does not work, we will make it work ;-)
>
>     my $cdata = $doc->createCDATASection($content);
>     my @req_params = (parameters => { xml => $cdata });
>
> Can you try this?  If you get errors, please reply to me off-list
> until we have a fix.  Hopefully we come to a text for the FAQ.
> --
> Regards,
>                MarkOv
>
> ------------------------------------------------------------------------
>        Mark Overmeer MSc                                MARKOV Solutions
>        Mark at Overmeer.net                          solutions at overmeer.net
> http://Mark.Overmeer.net                   http://solutions.overmeer.net
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/xml-compile/attachments/20180904/4fb67db0/attachment.htm>


More information about the Xml-compile mailing list