Hi everyone,
I have a little issue generating an XML. At first look, it seems that the XML is OK, but I find problem when I try to make a request with it.
The XML should have a field like this:
<collectionDateTime><![CDATA[2017-12-14T08:10:00]]></collectionDateTime>
I create the field in the XML like this:
lvl2XMlNode := XMLDocOut.createNode(1,'collectionDateTime','');
ConsigmentXMlNode.appendChild(lvl2XMlNode);
DomTextNode := XMLDocOut.createTextNode('<![CDATA[2017-12-14T11:35:00]]>');
lvl2XMlNode.appendChild(DomTextNode);
At the first look, I open the XML file with the briowser, and seems to be fine:
But the issue is that, this XML file is sent in a request in text format, and if I open it with the editor, I can see this:
collectionDateTime><![CDATA[2017-12-14T11:35:00]]></collectionDateTime>
So that provokes a marshalling error in the web service. How can I add the character correctly? I've tried to scape them in different ways, but i can't find the correct approach.
Any hint will be really appreciated.
Thanks!
Answers
This:
is invalid XML.
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Have you already tried to use next articles to create CDATA?
https://stackoverflow.com/questions/4679543/how-to-write-cdata-in-xml
https://msdn.microsoft.com/en-us/library/system.xml.xmldocument.createcdatasection.aspx
check this:
https://msdn.microsoft.com/en-us/library/system.xml.xmldocument.createcdatasection(v=vs.110).aspx
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
I am doing this noe:
And I receive this error:
"Error in the call to System.__ComObject.CreateCDataSection with the message: No valid data por a node of type 'CDATA'"
I've used the approach found in
https://forum.mibuso.com/discussion/comment/310306#Comment_310306
Try
Also, I guess, instead
should be
I'm creating the node this way:
The service is still returning me an error, but al least, this step is solved.
Thank you very much to both of you!